From e9390bb2697d8f61d1b2d6f9d4f3f09cc925d69e Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Sat, 31 Mar 2018 09:57:22 -0700 Subject: [PATCH] t/t2000-wreck-env.t: add tests for wreck global environment Add tests for wreck global environment lwj.environ, and corresponding commands to manipulate and use that environemnt. Note: the test is split from t2000-wreck.t but still prefixed with t2000 for easier test devlepment, parallel tests, etc. Since this is short-lived code, it is probably ok for now. --- t/Makefile.am | 2 ++ t/t2000-wreck-env.t | 49 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100755 t/t2000-wreck-env.t diff --git a/t/Makefile.am b/t/Makefile.am index b0bfc9af5dc4..f03e83472613 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -62,6 +62,7 @@ TESTS = \ t1105-proxy.t \ t1999-wreck-rcalc.t \ t2000-wreck.t \ + t2000-wreck-env.t \ t2001-jsc.t \ t2002-pmi.t \ t2003-recurse.t \ @@ -141,6 +142,7 @@ check_SCRIPTS = \ t1105-proxy.t \ t1999-wreck-rcalc.t \ t2000-wreck.t \ + t2000-wreck-env.t \ t2001-jsc.t \ t2002-pmi.t \ t2003-recurse.t \ diff --git a/t/t2000-wreck-env.t b/t/t2000-wreck-env.t new file mode 100755 index 000000000000..85eba0bddc56 --- /dev/null +++ b/t/t2000-wreck-env.t @@ -0,0 +1,49 @@ +#!/bin/sh +# + +test_description='Test basic wreck functionality + +Test basic functionality of wreckrun facility. +' + +. `dirname $0`/sharness.sh +SIZE=${FLUX_TEST_SIZE:-4} +test_under_flux ${SIZE} wreck + +# Return the previous jobid +last_job_id() { + flux wreck last-jobid +} +# Return previous job path in kvs +last_job_path() { + flux wreck last-jobid -p +} + +test_expect_success 'flux-wreck: setenv/getenv works' ' + flux wreck setenv FOO=BAR && + flux wreck getenv FOO +' +test_expect_success 'flux-wreck: unsetenv works' ' + flux wreck unsetenv FOO && + test "$(flux wreck getenv FOO)" = "FOO=" +' +test_expect_success 'flux-wreck: setenv all' ' + flux wreck setenv all && + flux env /usr/bin/env | sort | grep -ve FLUX_URI -e HOSTNAME -e ENVIRONMENT > env.expected && + flux wreck getenv | sort > env.output && + test_cmp env.expected env.output +' +test_expect_success 'wreck: global lwj.environ exported to jobs' ' + flux wreck setenv FOO=bar && + test "$(flux wreckrun -n1 printenv FOO)" = "bar" +' +test_expect_success 'wreck: wreckrun exports environment vars not in global env' ' + BAR=baz flux wreckrun -n1 printenv BAR > printenv.out && + test "$(cat printenv.out)" = "baz" +' +test_expect_success 'wreck: wreckrun --skip-env works' ' + BAR=baz flux wreckrun --skip-env -n1 printenv BAR > printenv2.out || : && + test "$(cat printenv2.out)" = "" +' + +test_done