Skip to content

Commit

Permalink
Merge pull request #6507 from garlick/path_true_false
Browse files Browse the repository at this point in the history
testsuite: don't assume /bin/true and /bin/false
  • Loading branch information
mergify[bot] authored Dec 13, 2024
2 parents 2ddf0d5 + cd2ef59 commit f26ecc0
Show file tree
Hide file tree
Showing 79 changed files with 388 additions and 388 deletions.
16 changes: 8 additions & 8 deletions src/broker/test/runat.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ void basic (flux_t *h)
"runat_is_defined name=test1 returns false");
ok (runat_is_completed (r, "test1") == false,
"runat_is_completed name=test1 returns false");
ok (runat_push_shell_command (r, "test1", "/bin/true", 0) == 0
&& runat_push_shell_command (r, "test1", "/bin/true", 0) == 0,
ok (runat_push_shell_command (r, "test1", "true", 0) == 0
&& runat_push_shell_command (r, "test1", "true", 0) == 0,
"pushed true;true");
ok (runat_is_defined (r, "test1") == true,
"runat_is_defined name=test1 returns true after creation");
Expand All @@ -101,8 +101,8 @@ void basic (flux_t *h)

/* run false;true */
clear_list (logs);
ok (runat_push_shell_command (r, "test2", "/bin/true", 0) == 0
&& runat_push_shell_command (r, "test2", "/bin/false", 0) == 0,
ok (runat_push_shell_command (r, "test2", "true", 0) == 0
&& runat_push_shell_command (r, "test2", "false", 0) == 0,
"pushed true;true");
ok (runat_start (r, "test2", test_completion, &ctx) == 0,
"runat_start works");
Expand All @@ -119,8 +119,8 @@ void basic (flux_t *h)

/* run true;false */
clear_list (logs);
ok (runat_push_command (r, "test3", "/bin/false", 11, 0) == 0
&& runat_push_command (r, "test3", "/bin/true", 10, 0) == 0,
ok (runat_push_command (r, "test3", "false", 6, 0) == 0
&& runat_push_command (r, "test3", "true", 5, 0) == 0,
"pushed true;true");
ok (runat_start (r, "test3", test_completion, &ctx) == 0,
"runat_start works");
Expand Down Expand Up @@ -221,9 +221,9 @@ void basic (flux_t *h)
#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 24)
flags |= RUNAT_FLAG_FORK_EXEC;
#endif
ok (runat_push_shell_command (r, "test7", "/bin/true", flags) == 0
ok (runat_push_shell_command (r, "test7", "true", flags) == 0
&& runat_push_shell_command (r, "test7", "sleep 3600", flags) == 0,
"pushed /bin/true;sleep 3600");
"pushed true;sleep 3600");
ok (runat_start (r, "test7", test_completion, &ctx) == 0,
"runat_start works");
ok (runat_abort (r, "test7") == 0,
Expand Down
4 changes: 2 additions & 2 deletions src/common/libsubprocess/test/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ void channel_nul_terminate_cb (flux_subprocess_t *p, const char *stream)

void test_bufsize (flux_reactor_t *r)
{
char *av[] = { "/bin/true", NULL };
char *av[] = { "true", NULL };
flux_cmd_t *cmd;
flux_subprocess_t *p = NULL;

Expand Down Expand Up @@ -427,7 +427,7 @@ void test_bufsize (flux_reactor_t *r)

void test_bufsize_error (flux_reactor_t *r)
{
char *av[] = { "/bin/true", NULL };
char *av[] = { "true", NULL };
flux_cmd_t *cmd;
flux_subprocess_t *p = NULL;
flux_subprocess_ops_t ops = {
Expand Down
10 changes: 5 additions & 5 deletions src/common/libsubprocess/test/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extern char **environ;

void corner_case_test (flux_t *h)
{
char *true_av[] = { "/bin/true", NULL };
char *true_av[] = { "true", NULL };
flux_subprocess_t *p;
flux_cmd_t *cmd;

Expand Down Expand Up @@ -243,20 +243,20 @@ void simple_test (flux_t *h)
{
struct simple_scorecard exp;

char *true_av[] = { "/bin/true", NULL };
char *true_av[] = { "true", NULL };
memset (&exp, 0, sizeof (exp));
exp.running = 1;
exp.exited = 1;
exp.completion = 1;
exp.stdout_eof = 1;
exp.stderr_eof = 1;
simple_run_check (h,
"/bin/true",
"true",
ARRAY_SIZE (true_av) - 1,
true_av,
&exp);

char *false_av[] = { "/bin/false", NULL };
char *false_av[] = { "false", NULL };
memset (&exp, 0, sizeof (exp));
exp.running = 1;
exp.exited = 1;
Expand All @@ -265,7 +265,7 @@ void simple_test (flux_t *h)
exp.stdout_eof = 1;
exp.stderr_eof = 1;
simple_run_check (h,
"/bin/false",
"false",
ARRAY_SIZE (false_av) - 1,
false_av,
&exp);
Expand Down
2 changes: 1 addition & 1 deletion src/common/libsubprocess/test/stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ void test_line_buffer_disable (flux_reactor_t *r)

void test_line_buffer_error (flux_reactor_t *r)
{
char *av[] = { "/bin/true", NULL };
char *av[] = { "true", NULL };
flux_cmd_t *cmd;
flux_subprocess_t *p = NULL;

Expand Down
28 changes: 14 additions & 14 deletions src/common/libsubprocess/test/subprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void completion_cb (flux_subprocess_t *p)
void test_corner_cases (flux_reactor_t *r)
{
flux_t *h = NULL;
char *avgood[] = { "/bin/true", NULL };
char *avgood[] = { "true", NULL };
char *avbad[] = { NULL };
flux_cmd_t *cmd;

Expand Down Expand Up @@ -106,7 +106,7 @@ void test_corner_cases (flux_reactor_t *r)
flux_cmd_destroy (cmd);

ok ((cmd = flux_cmd_create (1, avgood, NULL)) != NULL,
"flux_cmd_create with /bin/true works");
"flux_cmd_create with true works");
ok (flux_rexec (h, -10, 0, cmd, NULL) == NULL
&& errno == EINVAL,
"flux_rexec fails with cmd with invalid rank");
Expand Down Expand Up @@ -174,7 +174,7 @@ void test_corner_cases (flux_reactor_t *r)
"flux_subprocess_aux_get fails with NULL pointer input");

ok ((cmd = flux_cmd_create (1, avgood, NULL)) != NULL,
"flux_cmd_create with /bin/true works");
"flux_cmd_create with true works");
ok (flux_local_exec (r,
FLUX_SUBPROCESS_FLAGS_LOCAL_UNBUF,
cmd,
Expand All @@ -188,7 +188,7 @@ void test_corner_cases (flux_reactor_t *r)

void test_post_exec_errors (flux_reactor_t *r)
{
char *av[] = { "/bin/true", NULL };
char *av[] = { "true", NULL };
flux_cmd_t *cmd;
flux_subprocess_t *p = NULL;

Expand Down Expand Up @@ -256,7 +256,7 @@ void test_post_exec_errors (flux_reactor_t *r)

void test_basic (flux_reactor_t *r)
{
char *av[] = { "/bin/true", NULL };
char *av[] = { "true", NULL };
flux_cmd_t *cmd, *cmd2;
flux_reactor_t *r2;
flux_subprocess_t *p = NULL;
Expand Down Expand Up @@ -301,7 +301,7 @@ void completion_fail_cb (flux_subprocess_t *p)

void test_basic_fail (flux_reactor_t *r)
{
char *av[] = { "/bin/false", NULL };
char *av[] = { "false", NULL };
flux_cmd_t *cmd;
flux_subprocess_t *p = NULL;

Expand All @@ -326,7 +326,7 @@ void test_basic_fail (flux_reactor_t *r)

void test_flag_no_setpgrp (flux_reactor_t *r)
{
char *av[] = { "/bin/true", NULL };
char *av[] = { "true", NULL };
flux_cmd_t *cmd;
flux_subprocess_t *p = NULL;

Expand All @@ -351,7 +351,7 @@ void test_flag_no_setpgrp (flux_reactor_t *r)

void test_flag_fork_exec (flux_reactor_t *r)
{
char *av[] = { "/bin/true", NULL };
char *av[] = { "true", NULL };
flux_cmd_t *cmd;
flux_subprocess_t *p = NULL;

Expand Down Expand Up @@ -651,7 +651,7 @@ void state_change_cb (flux_subprocess_t *p, flux_subprocess_state_t state)

void test_state_change (flux_reactor_t *r)
{
char *av[] = { "/bin/true", NULL };
char *av[] = { "true", NULL };
flux_cmd_t *cmd;
flux_subprocess_t *p = NULL;

Expand Down Expand Up @@ -771,7 +771,7 @@ void test_exec_fail (flux_reactor_t *r)

void test_context (flux_reactor_t *r)
{
char *av[] = { "/bin/true", NULL };
char *av[] = { "true", NULL };
flux_cmd_t *cmd;
flux_subprocess_t *p = NULL;
char *extra = "mydata";
Expand Down Expand Up @@ -804,7 +804,7 @@ void test_context (flux_reactor_t *r)

void test_refcount (flux_reactor_t *r)
{
char *av[] = { "/bin/true", NULL };
char *av[] = { "true", NULL };
flux_cmd_t *cmd;
flux_subprocess_t *p = NULL;
char *extra = "mydata";
Expand Down Expand Up @@ -849,7 +849,7 @@ void shmem_hook_cb (flux_subprocess_t *p, void *arg)

void test_pre_exec_hook (flux_reactor_t *r)
{
char *av[] = { "/bin/true", NULL };
char *av[] = { "true", NULL };
flux_cmd_t *cmd;
flux_subprocess_t *p = NULL;
int *shmem_count;
Expand Down Expand Up @@ -900,7 +900,7 @@ void count_hook_cb (flux_subprocess_t *p, void *arg)

void test_post_fork_hook (flux_reactor_t *r)
{
char *av[] = { "/bin/true", NULL };
char *av[] = { "true", NULL };
flux_cmd_t *cmd;
flux_subprocess_t *p = NULL;
int hook_count = 0;
Expand Down Expand Up @@ -940,7 +940,7 @@ void destroy_in_completion_cb (flux_subprocess_t *p)

void test_destroy_in_completion (flux_reactor_t *r)
{
char *av[] = { "/bin/true", NULL };
char *av[] = { "true", NULL };
flux_cmd_t *cmd, *cmd2;
flux_reactor_t *r2;
flux_subprocess_t *p = NULL;
Expand Down
4 changes: 2 additions & 2 deletions src/common/libutil/test/popen2.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ int main(int argc, char** argv)
"popen2 /noexist failed with ENOENT");

/* open/close (child exit error) */
ok ((p = popen2 ("/bin/false", (char*[]){ "/bin/false", NULL }, 0)) != NULL,
"popen2 /bin/false OK");
ok ((p = popen2 ("false", (char*[]){ "false", NULL }, 0)) != NULL,
"popen2 false OK");
ok (pclose2 (p) == 0x100,
"pclose2 returns child exit code 1");

Expand Down
2 changes: 1 addition & 1 deletion t/issues/t4465-job-list-use-after-free.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mkdir ${STATEDIR}
# number of broker ranks.
#
flux start --test-size=8 -Sstatedir=${STATEDIR} \
bash -c "flux submit --cc 1-8 --quiet /bin/true && flux queue drain"
bash -c "flux submit --cc 1-8 --quiet true && flux queue drain"

flux start --test-size=1 -Sstatedir=${STATEDIR} \
--wrap=libtool,e,${VALGRIND} \
Expand Down
2 changes: 1 addition & 1 deletion t/issues/t4852-t_submit-legacy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
cat <<-EOF >t4852setup.sh
#!/bin/sh -e
jobid=\$(flux submit --wait /bin/true)
jobid=\$(flux submit --wait true)
kvspath=\$(flux job id --to=kvs \$jobid)
Expand Down
2 changes: 1 addition & 1 deletion t/issues/t5308-kvsdir-initial-path.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from flux.job import JobspecV1

handle = flux.Flux()
jobspec = JobspecV1.from_command(command=["/bin/true"], num_tasks=1, num_nodes=1)
jobspec = JobspecV1.from_command(command=["true"], num_tasks=1, num_nodes=1)
jobid = flux.job.submit(handle, jobspec, waitable=True)
flux.job.wait(handle, jobid=jobid)
jobdir = flux.job.job_kvs(handle, jobid)
Expand Down
2 changes: 1 addition & 1 deletion t/job-manager/submit-sliding-window.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# Open connection to broker
h = flux.Flux()

jobspec = JobspecV1.from_command(["/bin/true"])
jobspec = JobspecV1.from_command(["true"])
done = 0
running = 0

Expand Down
8 changes: 4 additions & 4 deletions t/job-manager/submit-wait.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
h = flux.Flux()

# Submit njobs test jobs (half will fail)
jobspec = JobspecV1.from_command(["/bin/true"])
jobspec_fail = JobspecV1.from_command(["/bin/false"])
jobspec = JobspecV1.from_command(["true"])
jobspec_fail = JobspecV1.from_command(["false"])
jobs = []
for i in range(njobs):
if i < njobs / 2:
jobid = job.submit(h, jobspec, waitable=True)
print("submit: {} /bin/true".format(jobid))
print("submit: {} true".format(jobid))
else:
jobid = job.submit(h, jobspec_fail, waitable=True)
print("submit: {} /bin/false".format(jobid))
print("submit: {} false".format(jobid))
jobs.append(jobid)

# Wait for each job in turn
Expand Down
8 changes: 4 additions & 4 deletions t/job-manager/submit-waitany.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
h = flux.Flux()

# Submit njobs test jobs (half will fail)
jobspec = JobspecV1.from_command(["/bin/true"])
jobspec_fail = JobspecV1.from_command(["/bin/false"])
jobspec = JobspecV1.from_command(["true"])
jobspec_fail = JobspecV1.from_command(["false"])
for i in range(njobs):
if i < njobs / 2:
jobid = job.submit(h, jobspec, waitable=True)
print("submit: {} /bin/true".format(jobid))
print("submit: {} true".format(jobid))
else:
jobid = job.submit(h, jobspec_fail, waitable=True)
print("submit: {} /bin/false".format(jobid))
print("submit: {} false".format(jobid))


# Wait for njobs jobs
Expand Down
4 changes: 2 additions & 2 deletions t/job-manager/wait-interrupted.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
h = flux.Flux()

# Submit njobs test jobs
jobspec = JobspecV1.from_command(["/bin/true"])
jobspec = JobspecV1.from_command(["true"])
jobs = []
for i in range(njobs):
jobid = job.submit(h, jobspec, waitable=True)
print("submit: {} /bin/true".format(jobid))
print("submit: {} true".format(jobid))
jobs.append(jobid)

# Async wait which we immediately abandon
Expand Down
6 changes: 3 additions & 3 deletions t/system/0004-recovery.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ test_expect_success 'dump the last checkpoint' '
sudo -u flux flux dump --checkpoint /tmp/dump.tar
'
test_expect_success 'flux start --recover fails when instance is running' '
test_must_fail sudo -u flux flux start --recover /bin/true
test_must_fail sudo -u flux flux start --recover true
'
test_expect_success 'stop the system instance' '
sudo flux shutdown
'
test_expect_success 'flux start --recover works' '
sudo -u flux flux start --recover /bin/true
sudo -u flux flux start --recover true
'
test_expect_success 'flux start --recover works from dump file' '
sudo -u flux flux start --recover=/tmp/dump.tar --sysconfig /bin/true
sudo -u flux flux start --recover=/tmp/dump.tar --sysconfig true
'
test_expect_success 'restart flux' '
sudo systemctl start flux
Expand Down
8 changes: 4 additions & 4 deletions t/system/0005-exec.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ test_expect_success 'start a long-running guest job' '
jobid=$(flux job last)
'
test_expect_success 'flux exec --jobid fails as guest' '
test_must_fail flux exec --jobid=$jobid /bin/true
test_must_fail flux exec --jobid=$jobid true
'
test_expect_success 'flux exec --jobid fails as instance owner' '
test_must_fail sudo -u flux flux exec --jobid=$jobid /bin/true
test_must_fail sudo -u flux flux exec --jobid=$jobid true
'
test_expect_success 'flux exec without --jobid works as instance owner' '
sudo -u flux flux exec -r 0 /bin/true
sudo -u flux flux exec -r 0 true
'
test_expect_success 'flux exec without --jobid fails as guest' '
test_must_fail flux exec -r 0 /bin/true
test_must_fail flux exec -r 0 true
'
test_expect_success 'cancel long-running job' '
flux cancel $jobid
Expand Down
2 changes: 1 addition & 1 deletion t/t0000-sharness.t
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ test_expect_success 'empty sharness.d directory does not cause failure' '
test_description="sharness works"
. ./sharness.sh
test_expect_success "test success" "
/bin/true
true
"
test_done
EOF
Expand Down
Loading

0 comments on commit f26ecc0

Please sign in to comment.