Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(944)

Side by Side Diff: make_tests.sh

Issue 2645008: Update on feedback, update dbus API, add unit tests. TEST=manual,unit,BVT BUG=3628 323 (Closed) Base URL: ssh://git@chromiumos-git/cryptohome.git
Patch Set: Address second round of feedback. Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « interface.cc ('k') | mock_mount.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 # 5 #
6 # Packages up tests for that they can run outside of the build tree. 6 # Packages up tests for that they can run outside of the build tree.
7 7
8 # Load common constants. This should be the first executable line. 8 # Load common constants. This should be the first executable line.
9 # The path to common.sh should be relative to your script's location. 9 # The path to common.sh should be relative to your script's location.
10 COMMON_SH="$(dirname "$0")/../../scripts/common.sh" 10 COMMON_SH="$(dirname "$0")/../../scripts/common.sh"
11 . "$COMMON_SH" 11 . "$COMMON_SH"
12 12
13 mkdir -p ${OUT_DIR} 13 mkdir -p ${OUT_DIR}
14 TARGET=${OUT_DIR}/cryptohome_tests 14 TARGET=${OUT_DIR}/cryptohome_test
15 15
16 # package_tests target runfile 16 # package_tests target initfile runfile
17 function package_tests() { 17 function package_tests() {
18 local package="$1" 18 local package="$1"
19 local testfile="$2" 19 local initfile="$2"
20 shift; shift 20 local testfile="$3"
21 local libs="$@" 21 shift; shift; shift
22 TMPDIR="${TMPDIR:-/tmp}" 22
23 local builddir="$(mktemp -d $TMPDIR/shpkgr.XXXXXX)" 23 local test_dir="test_image_dir"
24 eval "cleanup() { [[ -n \"$builddir\" ]] && rm -rf $builddir; }"
25 trap cleanup ERR
26 24
27 cat <<-EOF > $package 25 cat <<-EOF > $package
28 #!/bin/sh 26 #!/bin/sh
29 # Self extracting archive - reqs bash,test,rm,pwd,tar,gzip,tail,basename 27 # Self extracting archive - reqs bash,test,rm,pwd,tar,gzip,tail,basename
30 # Generated from "$0" 28 # Generated from "$0"
31 # export PKG_LEAVE_RUNFILES=1 to keep the exploded archive. 29 # export PKG_LEAVE_RUNFILES=1 to keep the exploded archive.
32 PREV=\`pwd\` 30 PREV=\`pwd\`
33 test \$? -eq 0 || exit 1 31 test \$? -eq 0 || exit 1
34 BASE=\`basename \$0\` 32 BASE=\`basename \$0\`
35 test \$? -eq 0 || exit 1 33 test \$? -eq 0 || exit 1
36 export RUNFILES=\`mktemp -d \$PREV/\$BASE.runfiles_XXXXXX\` 34 export RUNFILES=\`mktemp -d \$PREV/\$BASE.runfiles_XXXXXX\`
37 test \$? -eq 0 || exit 1 35 test \$? -eq 0 || exit 1
38 # delete the runfiles on exit using a trap 36 # delete the runfiles on exit using a trap
39 trap "test \$PKG_LEAVE_RUNFILES || rm -rf \$RUNFILES" EXIT 37 trap "test \$PKG_LEAVE_RUNFILES || rm -rf \$RUNFILES" EXIT
40 » # extract starting at the last line (20) 38 » # extract starting at the last line (21)
41 » tail -n +20 \$0 | gzip -dc | tar x -C \$RUNFILES 39 » tail -n +21 \$0 | base64 -d |tar xvf - -C \$RUNFILES
42 test \$? -eq 0 || exit 1 40 test \$? -eq 0 || exit 1
43 # execute the package but keep the current directory 41 # execute the package but keep the current directory
44 » /bin/bash --noprofile --norc -c "cd \$RUNFILES;. $testfile" \$0 "\$@" 42 » /bin/bash --noprofile --norc -c "cd \$RUNFILES;. $initfile $test_dir"
43 » /bin/bash --noprofile --norc -c "cd \$RUNFILES; ./$testfile" \$0 "\$@"
45 exit \$? 44 exit \$?
46 » __PACKAGER_TARBALL_GZ__ 45 » __PACKAGER_TARBALL__
47 EOF 46 EOF
48 pushd $builddir &> /dev/null 47 tar cvf - $initfile $testfile |base64 >> $package
49 local source="$OLDPWD/$(dirname $0)"
50 cp -r "$source/../../third_party/shunit2" shunit2
51 cp -r "$source/lib" lib
52 cp -r "$source/tests" tests
53 cp -a "$source/$testfile" $testfile
54 tar --exclude=".svn" --exclude=".git" -czf - * >> $package
55 popd &> /dev/null
56 trap - ERR
57 cleanup
58 chmod +x $package 48 chmod +x $package
59 } 49 }
60 50
61 package_tests "$TARGET" test.sh 51
52 SCRIPT_DIR=`dirname "$0"`
53 SCRIPT_DIR=`readlink -f "$SCRIPT_DIR"`
54
55 BUILD_ROOT=${BUILD_ROOT:-${SCRIPT_DIR}/../../../src/build}
56 mkdir -p $OUT_DIR
57
58 pushd $SCRIPT_DIR
59
60 scons cryptohome_testrunner
61 package_tests "$TARGET" init_cryptohome_data.sh cryptohome_testrunner
62
63 popd
OLDNEW
« no previous file with comments | « interface.cc ('k') | mock_mount.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698