From f4c1d44819c91cd1d50c5709c3dc89d6a9ddda1a Mon Sep 17 00:00:00 2001 From: Anh <zenpoems@gmail.com> Date: Thu, 22 Nov 2018 18:50:40 -0800 Subject: [PATCH] Add elfdep test Former-commit-id: b98b5790a4fc33d31656bb7b8c8a8d9d9fe49a12 --- .gitlab-ci.yml | 31 ++++++++++++++++++++++++ cicd_tests/elfdep.sh | 9 +++++++ libElfDep/test/test-elfdep.sh | 44 +++++++++++++++++++++++++++++++++++ libElfDep/test/testit.sh | 22 ------------------ 4 files changed, 84 insertions(+), 22 deletions(-) create mode 100755 cicd_tests/elfdep.sh create mode 100755 libElfDep/test/test-elfdep.sh delete mode 100755 libElfDep/test/testit.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b2dd1bfb6..1a3a2754b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -145,3 +145,34 @@ xform-cat-centos75: variables: OS: 'centos75' +# +# elfdep test +# + +# template +.elfdep: &elfdep + stage: test + script: + - ./cicd_tests/elfdep.sh + +elfdep-ubuntu18: + <<: *elfdep + tags: + - ubuntu18 + variables: + OS: 'ubuntu18' + +elfdep-ubuntu16: + <<: *elfdep + tags: + - ubuntu16 + variables: + OS: 'ubuntu16' + +elfdep-centos75: + <<: *elfdep + tags: + - centos75 + variables: + OS: 'centos75' + diff --git a/cicd_tests/elfdep.sh b/cicd_tests/elfdep.sh new file mode 100755 index 000000000..9ba43c87c --- /dev/null +++ b/cicd_tests/elfdep.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -e +set -x + +cd $CICD_MODULE_WORK_DIR/peasoup_umbrella +source set_env_vars + +cd $SECURITY_TRANSFORMS_HOME/libElfDep/test/ +./test-elfdep.sh diff --git a/libElfDep/test/test-elfdep.sh b/libElfDep/test/test-elfdep.sh new file mode 100755 index 000000000..39ac850f7 --- /dev/null +++ b/libElfDep/test/test-elfdep.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +TMP_ORIG=/tmp/testelfdep.ls.orig.$$ +TMP_ORIG2=/tmp/testelfdep.ls.orig.2.$$ +TMP_ELFDEP=/tmp/testelfdep.ls.elfdep.$$ + +cleanup_files() +{ + rm /tmp/testelfdep.ls* >/dev/null 2>&1 +} + +cleanup() +{ + echo "************" + echo "test failed." + echo "************" + + cleanup_files + exit 1 +} + + +# make sure xforms are built +scons || cleanup + +$PSZ /bin/ls ./xxx -c move_globals=on -o move_globals:--elftables -c edt=on || cleanup + +/bin/ls /tmp > $TMP_ORIG || cleanup + +./xxx /tmp > $TMP_ELFDEP || cleanup + +echo "Verify external vars was overwritten" +grep "var = 0" $TMP_ELFDEP || cleanup +grep "var = 1" $TMP_ELFDEP || cleanup + +echo "Verify same output" +grep -v "var =" $TMP_ELFDEP > $TMP_ORIG2 +diff $TMP_ORIG2 $TMP_ELFDEP + +cleanup_files + +echo +echo "test passed." +echo diff --git a/libElfDep/test/testit.sh b/libElfDep/test/testit.sh deleted file mode 100755 index 051b6c013..000000000 --- a/libElfDep/test/testit.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -cleanup() -{ - echo "************" - echo "test failed." - echo "************" - exit 1 -} - - -# make sure xforms are built -scons || cleanup - -$PSZ /bin/ls ./xxx -c move_globals=on -o move_globals:--elftables -c edt=on || cleanup - -/bin/ls /tmp || cleanup -./xxx /tmp || cleanup - -echo -echo "test passed." -echo -- GitLab