Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaudill committed Jul 24, 2024
1 parent 62fe3e2 commit 621b19a
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 67 deletions.
8 changes: 1 addition & 7 deletions lib/modify.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ class Modify_Mode(enum.Enum):
SCRIPT = "script"

def main(cli_):
global called
called = True

# Need to pass tree to build.py
global tree

# In this file, “cli” is used as a global variable
global cli
cli = cli_
Expand Down Expand Up @@ -200,7 +194,7 @@ def modify_tree_make_script(src_img, path):
WORD /path/to/script WORD /ch/script.sh
run
run_shell
LINE_CHUNK /ch/script.sh
LINE_CHUNK /bin/sh /ch/script.sh
"""
# Children of dockerfile tree
df_children = []
Expand Down
6 changes: 3 additions & 3 deletions test/build/50_ch-image.bats
Original file line number Diff line number Diff line change
Expand Up @@ -864,17 +864,17 @@ EOF
@test 'ch-run storage errors' {
run ch-run -v -w alpine:3.17 -- /bin/true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output = *'error: --write invalid when running by name'* ]]

run ch-run -v "$CH_IMAGE_STORAGE"/img/alpine+3.17 -- /bin/true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output = *"error: can't run directory images from storage (hint: run by name)"* ]]

run ch-run -v -s /doesnotexist alpine:3.17 -- /bin/true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output = *'warning: storage directory not found: /doesnotexist'* ]]
[[ $output = *"error: can't stat: alpine:3.17: No such file or directory"* ]]
}
Expand Down
2 changes: 1 addition & 1 deletion test/common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export BATS_TMPDIR=$btnew
[[ $(stat -c %a "$BATS_TMPDIR") = '700' ]]

# ch-run exit codes. (see also: ch_misc.h, lib/build.py)
CH_ERR_RUN=31
CH_ERR_MISC=31
CH_ERR_CMD=49
#CH_ERR_SQUASH=84 # Currently not used

Expand Down
6 changes: 3 additions & 3 deletions test/run/ch-run_escalated.bats
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ load ../common
[[ -g $ch_run_tmp ]]
run "$ch_run_tmp" --version
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output = *': please report this bug ('* ]]
rm "$ch_run_tmp"
}
Expand All @@ -32,7 +32,7 @@ load ../common
[[ -u $ch_run_tmp ]]
run "$ch_run_tmp" --version
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output = *': please report this bug ('* ]]
sudo rm "$ch_run_tmp"
}
Expand Down Expand Up @@ -71,7 +71,7 @@ load ../common
fi
run sudo -u root -g "$(id -gn)" "$ch_runfile" -v --version
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output = *'please report this bug ('* ]]
}

Expand Down
36 changes: 18 additions & 18 deletions test/run/ch-run_join.bats
Original file line number Diff line number Diff line change
Expand Up @@ -267,36 +267,36 @@ unset_vars () {
# --join but no join count
run ch-run --join "$ch_timg" -- true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output =~ 'join: no valid peer group size found' ]]
ipc_clean_p

# join count no digits
run ch-run --join-ct=a "$ch_timg" -- true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output =~ 'join-ct: no digits found' ]]
SLURM_CPUS_ON_NODE=a run ch-run --join "$ch_timg" -- true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output =~ 'SLURM_CPUS_ON_NODE: no digits found' ]]
ipc_clean_p

# join count empty string
run ch-run --join-ct='' "$ch_timg" -- true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output =~ '--join-ct: no digits found' ]]
SLURM_CPUS_ON_NODE=-1 run ch-run --join "$ch_timg" -- true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output =~ 'join: no valid peer group size found' ]]
ipc_clean_p

# --join-ct digits followed by extra goo (OK from environment variable)
run ch-run --join-ct=1a "$ch_timg" -- true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output =~ '--join-ct: extra characters after digits' ]]
ipc_clean_p

Expand All @@ -306,48 +306,48 @@ unset_vars () {
# join count above INT_MAX
run ch-run --join-ct=2147483648 "$ch_timg" -- true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output =~ $range_re ]]
SLURM_CPUS_ON_NODE=2147483648 \
run ch-run --join "$ch_timg" -- true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output =~ $range_re ]]
ipc_clean_p

# join count below INT_MIN
run ch-run --join-ct=-2147483649 "$ch_timg" -- true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output =~ $range_re ]]
SLURM_CPUS_ON_NODE=-2147483649 \
run ch-run --join "$ch_timg" -- true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output =~ $range_re ]]
ipc_clean_p

# join count above LONG_MAX
run ch-run --join-ct=9223372036854775808 "$ch_timg" -- true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output =~ $range_re ]]
SLURM_CPUS_ON_NODE=9223372036854775808 \
run ch-run --join "$ch_timg" -- true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output =~ $range_re ]]
ipc_clean_p

# join count below LONG_MIN
run ch-run --join-ct=-9223372036854775809 "$ch_timg" -- true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output =~ $range_re ]]
SLURM_CPUS_ON_NODE=-9223372036854775809 \
run ch-run --join "$ch_timg" -- true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output =~ $range_re ]]
ipc_clean_p
}
Expand All @@ -361,11 +361,11 @@ unset_vars () {
# join tag empty string
run ch-run --join-tag='' "$ch_timg" -- true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output =~ 'join: peer group tag cannot be empty string' ]]
SLURM_STEP_ID='' run ch-run --join "$ch_timg" -- true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output =~ 'join: peer group tag cannot be empty string' ]]
ipc_clean_p
}
Expand Down Expand Up @@ -466,14 +466,14 @@ unset_vars () {
# Can’t join namespaces of processes we don’t own.
run ch-run -v --join-pid=1 "$ch_timg" -- true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output = *"join: can't open /proc/1/ns/user: Permission denied"* ]]

# Can’t join namespaces of processes that don’t exist.
pid=2147483647
run ch-run -v --join-pid="$pid" "$ch_timg" -- true
echo "$output"
[[ $status -eq $CH_ERR_RUN ]]
[[ $status -eq $CH_ERR_MISC ]]
[[ $output = *"join: no PID ${pid}: /proc/${pid}/ns/user not found"* ]]
}

Expand Down
Loading

0 comments on commit 621b19a

Please sign in to comment.