Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ PAL_INCLUDE_DIR := $(SCXPAL_DIR)/source/code/include
PAL_TESTUTILS_DIR := $(SCXPAL_DIR)/test/code/testutils

INTERMEDIATE_DIR := $(BASE_DIR)/intermediate/$(BUILD_CONFIGURATION)
INTERMEDIATE_TESTFILES := $(INTERMEDIATE_DIR)/testfiles
TARGET_DIR := $(BASE_DIR)/target/$(BUILD_CONFIGURATION)
PROVIDER_LIBRARY := $(INTERMEDIATE_DIR)/libcontainer.so

Expand Down Expand Up @@ -304,7 +305,10 @@ TEST_STATUS:

test : TEST_STATUS $(SCXPAL_INTERMEDIATE_DIR) $(INTERMEDIATE_DIR)/testrunner
@echo "========================= Performing container testrun execution"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(OMI_ROOT)/output/lib; cd $(INTERMEDIATE_DIR); sudo ./testrunner
$(MKPATH) $(INTERMEDIATE_TESTFILES)
$(COPY) $(TEST_DIR)/scripts/createEnv.sh $(TEST_DIR)/scripts/testrun_wrapper $(INTERMEDIATE_TESTFILES)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(OMI_ROOT)/output/lib; cd $(INTERMEDIATE_TESTFILES); ./createEnv.sh
cd $(INTERMEDIATE_TESTFILES); ./testrun_wrapper $(INTERMEDIATE_DIR)

#--------------------------------------------------------------------------------
# Build the distribution kit
Expand Down Expand Up @@ -371,7 +375,7 @@ ifeq ($(ULINUX),1)
../installer/bundle/create_bundle.sh $(PF)_$(PF_DISTRO) $(INTERMEDIATE_DIR) $(OUTPUT_PACKAGE_PREFIX)
# Copy the shell bundle to the target directory
$(MKPATH) $(TARGET_DIR)
cd $(INTERMEDIATE_DIR); cp `cat $(INTERMEDIATE_DIR)/package_filename`.sh $(TARGET_DIR)
cd $(INTERMEDIATE_DIR); $(COPY) `cat $(INTERMEDIATE_DIR)/package_filename`.sh $(TARGET_DIR)

else

Expand Down
30 changes: 30 additions & 0 deletions test/code/scripts/createEnv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

# We need to set up some environment for the testrunner; do so here
# (Note that docker requires root privileges, so our environment must
# be set up for root access).

ENV_FILE=`dirname $0`/env.sh

echo "#!/bin/sh" > $ENV_FILE
echo >> $ENV_FILE

# Use the en_US locale for tests sensitive to date/time formatting
[ -z "$LANG" ] && LANG=`locale -a | grep -i en_us | grep -i utf`
echo "LANG=\"$LANG\"; export LANG" >> $ENV_FILE

# Export a variable solely so that we can see we're running under test
# This is not currently used, but gives us the option if we need it.
echo "CONTAINER_TESTRUN_ACTIVE=1; export CONTAINER_TESTRUN_ACTIVE" >> $ENV_FILE

# Testrunner arguments are sent using environment variables...
[ -n "$SCX_TESTRUN_NAMES" ] && echo "SCX_TESTRUN_NAMES=\"$SCX_TESTRUN_NAMES\"; export SCX_TESTRUN_NAMES" >> $ENV_FILE
[ -n "$SCX_TESTRUN_ATTRS" ] && echo "SCX_TESTRUN_ATTRS=\"$SCX_TESTRUN_ATTRS\"; export SCX_TESTRUN_ATTRS" >> $ENV_FILE

# Other environment variables for tests to run properly
[ -n "$LD_LIBRARY_PATH" ] && echo "LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH\"; export LD_LIBRARY_PATH" >> $ENV_FILE

# Code coverage (BullsEye) environment
[ -n "$COVFILE" ] && echo "COVFILE=\"$COVFILE\"; export COVFILE" >> $ENV_FILE

exit 0
22 changes: 22 additions & 0 deletions test/code/scripts/testrun_wrapper
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

if [ -z "$1" ]; then
echo "$0 must be run with at least one parameter"
exit 1
fi

# There might be an environment shell script created by
# "somebody else" in the current directory, if so run
# the tests using those variables
ENV_FILE=`dirname $0`/env.sh
SOURCE_ENV=""
if [ -f $ENV_FILE ]; then SOURCE_ENV=". $ENV_FILE $1;"; fi

# Execute the testrunner with root privileges
sudo sh -c "$SOURCE_ENV $1/testrunner $2 $3"
# Preserve exit status
exit_status=$?
# Make sure any files created during testrun can be removed
sudo chown -R $USER $1/*
# Return with exit status from the test run
exit $exit_status