From b1cf7b088adcef207330e13bd896b8b0940ae098 Mon Sep 17 00:00:00 2001 From: Morris Jette <jette@schedmd.com> Date: Wed, 7 Feb 2018 13:35:56 -0700 Subject: [PATCH] harden test38.6 more --- testsuite/expect/test38.6 | 19 +++++++++++++------ testsuite/expect/test38.6.prog.c | 21 +++++++++++++-------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/testsuite/expect/test38.6 b/testsuite/expect/test38.6 index 9c597493de8..a91cfa26d0b 100755 --- a/testsuite/expect/test38.6 +++ b/testsuite/expect/test38.6 @@ -276,18 +276,23 @@ if {[wait_for_file $file_out] == 0} { wait } } + set fail_cnt 0 if {$matches_sbatch != 2} { send_user "\nFAILURE: local (sbatch) sbatch spank plugin failure ($matches_sbatch != 2)\n" - end_it 1 - } elseif {$matches_srun != 2} { + set fail_cnt 1 + } + if {$matches_srun != 2} { send_user "\nFAILURE: local (srun) srun spank plugin failure ($matches_srun != 2)\n" - end_it 1 - } elseif {$matches != 2} { + set fail_cnt 1 + } + if {$matches != 2} { send_user "\nFAILURE: local (srun) spank plugin failure ($matches != 2)\n" + set fail_cnt 1 + } + if {$fail_cnt != 0} { end_it 1 - } else { - send_user "\nlocal (srun) spank plugin success\n" } + send_user "\nlocal (srun) spank plugin success\n" } else { end_it 1 } @@ -363,6 +368,8 @@ if {[wait_for_file $spank_out] == 0} { end_it 1 } send_user "\nRemote (slurmd) spank plugin success\n" +} else { + end_it 1 } end_it $exit_code diff --git a/testsuite/expect/test38.6.prog.c b/testsuite/expect/test38.6.prog.c index 08c29b27eaa..a2d06784b56 100644 --- a/testsuite/expect/test38.6.prog.c +++ b/testsuite/expect/test38.6.prog.c @@ -147,16 +147,19 @@ int slurm_spank_task_init(spank_t sp, int ac, char **av) char hostname[64] = ""; gethostname(hostname, sizeof(hostname)); - if (opt_out_file) { + if (opt_out_file && (opt_arg_sbatch || opt_arg_srun)) { FILE *fp = NULL; + usleep(getpid() % 500000); /* Reduce NFS collisions */ for (i = 0; (i < 10) && !fp; i++) fp = fopen(opt_out_file, "a"); - if (!fp) + if (!fp) { + slurm_error("%s: could not open %s", + __func__, opt_out_file); return -1; - if (opt_arg_sbatch || opt_arg_srun) - usleep(getpid() % 500000); /* Reduce NFS collisions */ + } fprintf(fp, "%s: opt_arg_sbatch=%d opt_arg_srun=%d hostname=%s\n", __func__, opt_arg_sbatch, opt_arg_srun, hostname); + fflush(fp); if (spank_get_item(sp, S_JOB_UID, &my_uid) == ESPANK_SUCCESS) fprintf(fp, "spank_get_item: my_uid=%d\n", my_uid); if (spank_get_item(sp, S_JOB_ARGV, &argc, &argv) == @@ -189,14 +192,16 @@ int slurm_spank_exit(spank_t sp, int ac, char **av) int i; gethostname(hostname, sizeof(hostname)); - if (opt_out_file) { + if (opt_out_file && (opt_arg_sbatch || opt_arg_srun)) { FILE *fp = NULL; + usleep(getpid() % 500000); /* Reduce NFS collisions */ for (i = 0; (i < 10) && !fp; i++) fp = fopen(opt_out_file, "a"); - if (!fp) + if (!fp) { + slurm_error("%s: could not open %s", + __func__, opt_out_file); return -1; - if (opt_arg_sbatch || opt_arg_srun) - usleep(getpid() % 500000); /* Reduce NFS collisions */ + } fprintf(fp, "%s: opt_arg_sbatch=%d opt_arg_srun=%d hostname=%s\n", __func__, opt_arg_sbatch, opt_arg_srun, hostname); fclose(fp); -- GitLab