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

Commit

Permalink
update test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaudill committed Apr 22, 2024
1 parent 491ce01 commit 6f8014e
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 66 deletions.
10 changes: 5 additions & 5 deletions bin/ch-run.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ int main(int argc, char *argv[])

if (arg_next >= argc - 1) {
printf("usage: ch-run [OPTION...] IMAGE -- COMMAND [ARG...]\n");
FATAL("IMAGE and/or COMMAND not specified");
FATAL(0, "IMAGE and/or COMMAND not specified");
}
args.c.img_ref = argv[arg_next++];
args.c.newroot = realpath_(args.c.newroot, true);
Expand All @@ -210,11 +210,11 @@ int main(int argc, char *argv[])
break;
case IMG_SQUASH:
#ifndef HAVE_LIBSQUASHFUSE
FATAL("this ch-run does not support internal SquashFS mounts");
FATAL(0, "this ch-run does not support internal SquashFS mounts");
#endif
break;
case IMG_NONE:
FATAL("unknown image type: %s", args.c.img_ref);
FATAL(0, "unknown image type: %s", args.c.img_ref);
break;
}

Expand Down Expand Up @@ -461,7 +461,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)
#endif
}
else
FATAL("unknown feature: %s", arg);
FATAL(0, "unknown feature: %s", arg);
break;
case -12: // --home
Tf (args->c.host_home = getenv("HOME"), "--home failed: $HOME not set");
Expand Down Expand Up @@ -492,7 +492,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state)
else if (!strcmp(arg, "log-fail"))
test_logging(true);
else
FATAL("invalid --test argument: %s; see source code", arg);
FATAL(0, "invalid --test argument: %s; see source code", arg);
break;
case 'b': { // --bind
char *src, *dst;
Expand Down
8 changes: 3 additions & 5 deletions bin/ch_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void bind_mount(const char *src, const char *dst, enum bind_dep dep,
if (!path_exists(dst_full, NULL, true))
switch (dep) {
case BD_REQUIRED:
FATAL("can't bind: destination not found: %s", dst_full);
FATAL(0, "can't bind: destination not found: %s", dst_full);
break;
case BD_OPTIONAL:
return;
Expand Down Expand Up @@ -400,7 +400,7 @@ enum img_type image_type(const char *ref, const char *storage_dir)
return IMG_SQUASH;

// Well now we’re stumped.
FATAL("unknown image type: %s", ref);
FATAL(0, "unknown image type: %s", ref);
}

char *img_name2path(const char *name, const char *storage_dir)
Expand Down Expand Up @@ -546,9 +546,7 @@ void run_user_command(char *argv[], const char *initial_dir)
if (verbose < LL_STDERR)
T_ (freopen("/dev/null", "w", stderr));
execvp(argv[0], argv); // only returns if error
//Tf (0, "can't execve(2): %s", argv[0]);
//Terror (0, "can't execve(2): %s", argv[0]);
ERROR("can't execve(2): %s", argv[0])
ERROR(errno, "can't execve(2): %s", argv[0]);
exit(ERR_CMD);
}

Expand Down
2 changes: 1 addition & 1 deletion bin/ch_fuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void sq_mount(const char *img_path, char *mountpt)
&OPS, sizeof(OPS), sq.ll)) {
break; // success
} else if (i <= 0) {
FATAL("too many FUSE errors; giving up");
FATAL(0, "too many FUSE errors; giving up");
} else {
WARNING("FUSE error mounting SquashFS; will retry");
sleep(1);
Expand Down
4 changes: 2 additions & 2 deletions bin/ch_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ void test_logging(bool fail) {
INFO("info");
WARNING("warning");
if (fail)
FATAL("the program failed inexplicably (\"log-fail\" specified)");
FATAL(0, "the program failed inexplicably (\"log-fail\" specified)");
exit(0);
}

Expand Down Expand Up @@ -587,7 +587,7 @@ void msg(enum log_level level, const char *file, int line, int errno_,
}

void msg_error(const char *file, int line, int errno_,
const char *fmt, ...)
const char *fmt, ...)
{
va_list ap;

Expand Down
14 changes: 7 additions & 7 deletions bin/ch_misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@
#define Zf(x, ...) if (x) msg_fatal(__FILE__, __LINE__, errno, __VA_ARGS__)
#define Ze(x, ...) if (x) msg_fatal(__FILE__, __LINE__, 0, __VA_ARGS__)

#define FATAL(...) msg_fatal( __FILE__, __LINE__, 0, __VA_ARGS__);
#define ERROR(...) msg_error( __FILE__, __LINE__, 0, __VA_ARGS__);
#define WARNING(...) msg(LL_WARNING, __FILE__, __LINE__, 0, __VA_ARGS__);
#define INFO(...) msg(LL_INFO, __FILE__, __LINE__, 0, __VA_ARGS__);
#define VERBOSE(...) msg(LL_VERBOSE, __FILE__, __LINE__, 0, __VA_ARGS__);
#define DEBUG(...) msg(LL_DEBUG, __FILE__, __LINE__, 0, __VA_ARGS__);
#define TRACE(...) msg(LL_TRACE, __FILE__, __LINE__, 0, __VA_ARGS__);
#define FATAL(e, ...) msg_fatal( __FILE__, __LINE__, e, __VA_ARGS__);
#define ERROR(e, ...) msg_error( __FILE__, __LINE__, e, __VA_ARGS__);
#define WARNING(...) msg(LL_WARNING, __FILE__, __LINE__, 0, __VA_ARGS__);
#define INFO(...) msg(LL_INFO, __FILE__, __LINE__, 0, __VA_ARGS__);
#define VERBOSE(...) msg(LL_VERBOSE, __FILE__, __LINE__, 0, __VA_ARGS__);
#define DEBUG(...) msg(LL_DEBUG, __FILE__, __LINE__, 0, __VA_ARGS__);
#define TRACE(...) msg(LL_TRACE, __FILE__, __LINE__, 0, __VA_ARGS__);


/** Types **/
Expand Down
10 changes: 7 additions & 3 deletions lib/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,18 +322,22 @@ def modify(cli_):
fake_sid = uuid.uuid4()
out_image.unpack_clear()
out_image.copy_unpacked(src_image)
bu.cache.worktree_adopt(out_image, "root")
bu.cache.worktree_adopt(out_image, src_image.ref.for_path)
bu.cache.ready(out_image)
bu.cache.branch_nocheckout(src_image.ref, out_image.ref)
foo = subprocess.run([ch.CH_BIN + "/ch-run", "--unsafe", "-w",
str(out_image.ref), "--", shell])
if (foo.returncode == 57):
if (foo.returncode == 58):
# FIXME: Write a better error message?
ch.FATAL("Unable to run shell: %s" % shell)
ch.ILLERI("retcode: %s" % foo.returncode)
ch.VERBOSE("using SID %s" % fake_sid)
bu.cache.commit(out_image.unpack_path, fake_sid, "MODIFY interactive", [])
# FIXME: metadata history stuff? See misc.import_.
if (out_image.metadata["history"] == []):
out_image.metadata["history"].append({ "empty_layer": False,
"command": "ch-image import"})
out_image.metadata_save()
bu.cache.commit(out_image.unpack_path, fake_sid, "MODIFY interactive", [])

def modify_tree_make(src_img, cmds):
"""Function that manually constructs a parse tree corresponding to a set of
Expand Down
4 changes: 2 additions & 2 deletions test/build/50_ch-image.bats
Original file line number Diff line number Diff line change
Expand Up @@ -869,12 +869,12 @@ EOF

run ch-run -v "$CH_IMAGE_STORAGE"/img/alpine+3.17 -- /bin/true
echo "$output"
[[ $status -eq 1 ]]
[[ $status -eq 57 ]]
[[ $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 1 ]]
[[ $status -eq 57 ]]
[[ $output = *'warning: storage directory not found: /doesnotexist'* ]]
[[ $output = *"error: can't stat: alpine:3.17: No such file or directory"* ]]
}
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 1 ]]
[[ $status -eq 57 ]]
[[ $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 1 ]]
[[ $status -eq 57 ]]
[[ $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 1 ]]
[[ $status -eq 57 ]]
[[ $output = *'please report this bug ('* ]]
}

Expand Down
34 changes: 17 additions & 17 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 1 ]]
[[ $status -eq 57 ]]
[[ $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 1 ]]
[[ $status -eq 57 ]]
[[ $output =~ 'join-ct: no digits found' ]]
SLURM_CPUS_ON_NODE=a run ch-run --join "$ch_timg" -- true
echo "$output"
[[ $status -eq 1 ]]
[[ $status -eq 57 ]]
[[ $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 1 ]]
[[ $status -eq 57 ]]
[[ $output =~ '--join-ct: no digits found' ]]
SLURM_CPUS_ON_NODE=-1 run ch-run --join "$ch_timg" -- true
echo "$output"
[[ $status -eq 1 ]]
[[ $status -eq 57 ]]
[[ $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 1 ]]
[[ $status -eq 57 ]]
[[ $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 1 ]]
[[ $status -eq 57 ]]
[[ $output =~ $range_re ]]
SLURM_CPUS_ON_NODE=2147483648 \
run ch-run --join "$ch_timg" -- true
echo "$output"
[[ $status -eq 1 ]]
[[ $status -eq 57 ]]
[[ $output =~ $range_re ]]
ipc_clean_p

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

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

# join count below LONG_MIN
run ch-run --join-ct=-9223372036854775809 "$ch_timg" -- true
echo "$output"
[[ $status -eq 1 ]]
[[ $status -eq 57 ]]
[[ $output =~ $range_re ]]
SLURM_CPUS_ON_NODE=-9223372036854775809 \
run ch-run --join "$ch_timg" -- true
echo "$output"
[[ $status -eq 1 ]]
[[ $status -eq 57 ]]
[[ $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 1 ]]
[[ $status -eq 57 ]]
[[ $output =~ 'join: peer group tag cannot be empty string' ]]
SLURM_STEP_ID='' run ch-run --join "$ch_timg" -- true
echo "$output"
[[ $status -eq 1 ]]
[[ $status -eq 57 ]]
[[ $output =~ 'join: peer group tag cannot be empty string' ]]
ipc_clean_p
}
Expand Down Expand Up @@ -473,7 +473,7 @@ unset_vars () {
pid=2147483647
run ch-run -v --join-pid="$pid" "$ch_timg" -- true
echo "$output"
[[ $status -eq 1 ]]
[[ $status -eq 57 ]]
[[ $output = *"join: no PID ${pid}: /proc/${pid}/ns/user not found"* ]]
}

Expand Down
Loading

0 comments on commit 6f8014e

Please sign in to comment.