From a221aab08c849a09c09cd526cbd3df924d9d6998 Mon Sep 17 00:00:00 2001 From: Chris Sosa Date: Wed, 17 Feb 2010 16:38:21 -0800 Subject: [PATCH] Adds changes to unittest scripts to use ebuild if board is specified Review URL: http://codereview.chromium.org/614005 --- build_tests.sh | 32 +++++++++++++++++++++----------- run_tests.sh | 28 ++++++++++++++++++++-------- 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/build_tests.sh b/build_tests.sh index a057b60e67..895c5e572f 100755 --- a/build_tests.sh +++ b/build_tests.sh @@ -12,6 +12,9 @@ assert_inside_chroot assert_not_root_user # Flags +DEFINE_string build_root "$DEFAULT_BUILD_ROOT" \ + "Root of build output" +DEFINE_string board "" "Target board for which tests are to be built" # Parse command line FLAGS "$@" || exit 1 @@ -20,16 +23,23 @@ eval set -- "${FLAGS_ARGV}" # Die on error; print commands set -e -PLATFORM_DIR="$SRC_ROOT/platform" -PLATFORM_DIRS="pam_google window_manager cryptohome" +TEST_DIRS="pam_google window_manager cryptohome" -# Build tests -for i in $PLATFORM_DIRS -do - echo "building $PLATFORM_DIR/$i" - cd "$PLATFORM_DIR/$i" - ./make_tests.sh - cd - -done +if [ -n "$FLAGS_board" ] +then + sudo TEST_DIRS="${TEST_DIRS}" \ + emerge-${FLAGS_board} chromeos-base/chromeos-unittests +else + PLATFORM_DIR="$SRC_ROOT/platform" + + # Build tests + for i in ${TEST_DIRS} + do + echo "building $PLATFORM_DIR/$i" + cd "$PLATFORM_DIR/$i" + OUT_DIR="${FLAGS_build_root}/x86/tests" ./make_tests.sh + cd - + done -echo "All tests built." + echo "All tests built." +fi diff --git a/run_tests.sh b/run_tests.sh index 7965ba162e..734f7c8f53 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -11,6 +11,8 @@ # Flags DEFINE_string build_root "$DEFAULT_BUILD_ROOT" \ "Root of build output" +DEFINE_string board "" \ + "Target board of which tests were built" # Parse command line FLAGS "$@" || exit 1 @@ -20,11 +22,21 @@ eval set -- "${FLAGS_ARGV}" set -ex # Run tests -TESTS_DIR="$FLAGS_build_root/x86/tests" -cd "$TESTS_DIR" - -# TODO: standardize test names - should all end in "_test" -for i in *_test *_tests *_unittests; do ./${i}; done - -cd - -echo "All tests passed." +if [ -n "$FLAGS_board" ] +then + TESTS_DIR="/build/${FLAGS_board}/tests" + echo "Not implemented" >&2 + exit 1 + + # TODO(sosa@chromium.org) - Call autotest job to run tests from TESTS_DIR + # using run_remote_tests +else + TESTS_DIR="$FLAGS_build_root/x86/tests" + cd "$TESTS_DIR" + + # TODO: standardize test names - should all end in "_test" + for i in *_test *_tests *_unittests; do ! ./${i}; done + + cd - + echo "All tests passed." +fi