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

Side by Side Diff: run_tests.sh

Issue 2833006: Eliminate stale pkcs11 certificate handler implementations. (Closed) Base URL: ssh://git@chromiumos-git/entd.git
Patch Set: Changed default pkcs11 mode and updated tests. 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 | « pkcs11.cc ('k') | no next file » | 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 2
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # TODO: Get these tests running in a cross-platform fashion from the src_test 7 # TODO: Get these tests running in a cross-platform fashion from the src_test
8 # stanza of the entd ebuild. 8 # stanza of the entd ebuild.
9 9
10 USERNAME="user@google.com" 10 USERNAME="user@google.com"
11 ALLOW_DIRTY_EXIT=1 11 ALLOW_DIRTY_EXIT=1
12 PKCS11_TEST=1
12 grep "Chromium OS" /etc/lsb-release 13 grep "Chromium OS" /etc/lsb-release
13 if [ $? == 0 ]; then 14 if [ $? == 0 ]; then
14 CHROMEOS=1 15 CHROMEOS=1
15 ENTD="/usr/sbin/entd" 16 ENTD="/usr/sbin/entd"
16 else 17 else
17 CHROMEOS=0 18 CHROMEOS=0
18 ENTD="../../scripts/run_32bit.sh out/i686-pc-linux-gnu/entd --" 19 ENTD="../../scripts/run_32bit.sh out/i686-pc-linux-gnu/entd --"
19 fi 20 fi
20 21
21 # If non-zero, print test output on failure 22 # If non-zero, print test output on failure
(...skipping 16 matching lines...) Expand all
38 # Test by running entd with some command line options and grepping the 39 # Test by running entd with some command line options and grepping the
39 # output for an expected pattern. 40 # output for an expected pattern.
40 local args="$1" 41 local args="$1"
41 local pattern="$2" 42 local pattern="$2"
42 local name="$3" 43 local name="$3"
43 44
44 if [ -z "$name" ]; then 45 if [ -z "$name" ]; then
45 name=$args 46 name=$args
46 fi 47 fi
47 48
49 local expected_result="$4"
50
51 if [ -z "$expected_result" ]; then
52 expected_result=0
53 fi
54
55
48 if [ ${args:0:2} != "--" ]; then 56 if [ ${args:0:2} != "--" ]; then
49 # allow callers to just pass the name of the js file if that's all they need 57 # allow callers to just pass the name of the js file if that's all they need
50 args="--policy=test_data/$args" 58 args="--policy=test_data/$args"
51 fi 59 fi
52 60
53 local cmd="$ENTD --username=$USERNAME $args" 61 local cmd="$ENTD --username=$USERNAME $args"
54 if [ ! -z "$ALLOW_DIRTY_EXIT" ]; then 62 if [ ! -z "$ALLOW_DIRTY_EXIT" ]; then
55 cmd="$cmd --allow-dirty-exit" 63 cmd="$cmd --allow-dirty-exit"
56 fi 64 fi
57 65
58 local out=$($cmd 2>&1) 66 if [ ! -z "$PKCS11_TEST" ]; then
67 cmd="$cmd --pkcs11=test"
68 fi
69
70 local out
71 out=$($cmd 2>&1)
59 local code=$? 72 local code=$?
60 73
61 TESTS=$(($TESTS +1)) 74 TESTS=$(($TESTS +1))
62 75
63 if [ $code != 0 ]; then 76 if [ $code != $expected_result ]; then
64 logfail "$name: exited with $code" 77 logfail "$name: exited with $code"
65 return 78 return
66 fi 79 fi
67 80
68 grep -q "$pattern" <(echo $out) 81 grep -q "$pattern" <(echo $out)
69 if [ $? != 0 ]; then 82 if [ $? != 0 ]; then
70 logfail "$name: pattern not found: '$pattern'" 83 logfail "$name: pattern not found: '$pattern'"
71 if [ ! -z "$VERBOSE" ]; then 84 if [ ! -z "$VERBOSE" ]; then
72 echo 85 echo
73 echo $cmd 86 echo $cmd
74 echo 87 echo
75 echo "=== OUTPUT START" 88 echo "=== OUTPUT START"
76 echo $out 89 echo $out
77 echo "=== OUTPUT END" 90 echo "=== OUTPUT END"
78 echo 91 echo
79 fi 92 fi
80 else 93 else
81 logpass "$name" 94 logpass "$name"
82 fi 95 fi
83 } 96 }
84 97
85 # Basic tests. 98 # Basic tests.
86 greptest "hello-world.js" 'hello world' 99 greptest "hello-world.js" 'hello world'
87 greptest "bad-onload.js" 'throw "expected exception"' 100 greptest "bad-onload.js" 'throw "expected exception"' '' 1
88 greptest "print-username.js" "username: $USERNAME" 101 greptest "print-username.js" "username: $USERNAME"
89 greptest "throw-exception.js" 'throw "goodbye world"' 102 greptest "throw-exception.js" 'throw "goodbye world"' '' 1
90 greptest "syslog.js" "entd.syslog.error" 103 greptest "syslog.js" "entd.syslog.error"
91 greptest "simple-hostname.js" "LOOKS OK" 104 greptest "simple-hostname.js" "LOOKS OK"
92 greptest "simple-onunload.js" "LOOKS OK" 105 greptest "simple-onunload.js" "LOOKS OK"
93 106
94 # Basic tests with longer command lines. 107 # Basic tests with longer command lines.
95 greptest "--policy=test_data/print-manifest.js \ 108 greptest "--policy=test_data/print-manifest.js \
96 --manifest=test_data/simple-manifest.json" '{"foo":1,"bar":2}' \ 109 --manifest=test_data/simple-manifest.json" '{"foo":1,"bar":2}' \
97 "print-manifest.js" 110 "print-manifest.js"
98 greptest "--policy=test_data/simple-utility.js \ 111 greptest "--policy=test_data/simple-utility.js \
99 --utility=test_data/simple-utility.js" 'utility is set' "simple-utility.js" 112 --utility=test_data/simple-utility.js" 'utility is set' "simple-utility.js"
100 greptest "--extension-path=test_data/Extensions" '{"foo":1,"bar":2}' 113 greptest "--extension-path=test_data/Extensions" '{"foo":1,"bar":2}'
101 114
102 # Http tests. 115 # Http tests.
103 greptest "http-good.js" "HTTP COMPLETE" 116 greptest "http-good.js" "HTTP COMPLETE"
104 greptest "http-badhost.js" "HTTP ERROR: Couldn't resolve" 117 greptest "http-badhost.js" "HTTP ERROR: Couldn't resolve"
105 greptest "http-badport.js" "LOOKS OK" 118 greptest "http-badport.js" "LOOKS OK"
106 greptest "http-evilhost.js" "Invalid hostname" 119 greptest "http-evilhost.js" "Invalid hostname" '' 1
107 greptest "http-badrequest.js" "First argument must be a Request object" 120 greptest "http-badrequest.js" "First argument must be a Request object" '' 1
108 greptest "http-redirect.js" "HTTP COMPLETE" 121 greptest "http-redirect.js" "HTTP COMPLETE"
109 122
110 # Pkcs11 tests. 123 # Pkcs11 tests.
111 greptest 'pkcs11.js '\ 124 greptest 'pkcs11.js '\
112 '--allow-file-io' \ 125 '--allow-file-io' \
113 '{"slot1":{"label":"slot1","keyIdentifier":"key1",'\ 126 '{"slot1":{"label":"slot1","keyIdentifier":"key1",'\
114 '"certificate":{"subject":"Content"}},'\ 127 '"certificate":{"subject":"Test"}},'\
115 '"slot2":{"label":"slot2","keyIdentifier":"key2",'\ 128 '"slot2":{"label":"slot2","keyIdentifier":"key2",'\
116 '"certificate":{"subject":"Content"}}}' \ 129 '"certificate":{"subject":"Test"}}}' \
117 "pkcs11.js" 130 "pkcs11.js"
118 greptest 'pkcs11-cert.js '\ 131 greptest 'pkcs11-cert.js '\
119 '--allow-file-io' \ 132 '--allow-file-io' \
120 '{"slot1":{"label":"slot1","certificate":{"subject":"Content"}}}' \ 133 '{"slot1":{"label":"slot1","certificate":{"subject":"Test"}}}' \
121 "pkcs11-cert.js" 134 "pkcs11-cert.js"
135 greptest "pkcs11-remove.js" "Slot1: undefined"
136
137 PKCS11_TEST=
122 greptest 'pkcs11-openssl.js '\ 138 greptest 'pkcs11-openssl.js '\
123 '--pkcs11=openssl --allow-file-io' \ 139 '--pkcs11=openssl --allow-file-io' \
124 'Subject:/C=US/ST=California/L=Mountain View/O=Google Inc/OU=ChromeOS' \ 140 'Subject:/C=US/ST=California/L=Mountain View/O=Google Inc/OU=ChromeOS' \
125 "pkcs11-openssl.js" 141 "pkcs11-openssl.js"
126 greptest "pkcs11-remove.js" "Slot1: undefined"
127 142
128 # Pkcs11 opencryptoki tests (requires a TPM (or emulator), so chromeos only) 143 # Pkcs11 opencryptoki tests (requires a TPM (or emulator), so chromeos only)
129 if [ "$CHROMEOS" == 1 ]; then 144 if [ "$CHROMEOS" == 1 ]; then
130 greptest 'pkcs11-opencryptoki.js '\ 145 greptest 'pkcs11-opencryptoki.js '\
131 '--pkcs11=glaptop --allow-file-io' \ 146 '--allow-file-io' \
132 '"slot1":{"label":"slot1","keyIdentifier":"1234",'\ 147 '"slot1":{"label":"slot1","keyIdentifier":"1234",'\
133 '"certificate":{'\ 148 '"certificate":{'\
134 '"subject":"/C=US/ST=California/L=Mountain View/O=Google Inc/OU=ChromeOS' \ 149 '"subject":"/C=US/ST=California/L=Mountain View/O=Google Inc/OU=ChromeOS' \
135 "pkcs11-opencryptoki.js" 150 "pkcs11-opencryptoki.js"
136 greptest 'pkcs11-opencryptoki-delete.js '\ 151 greptest 'pkcs11-opencryptoki-delete.js '\
137 '--pkcs11=glaptop --allow-file-io' \ 152 '--allow-file-io' \
138 'Slots.slot1: undefined' \ 153 'Slots.slot1: undefined' \
139 "pkcs11-opencryptoki-delete.js" 154 "pkcs11-opencryptoki-delete.js"
140 fi 155 fi
156 PKCS11_TEST=1
157
141 # Slightly longer running tests. 158 # Slightly longer running tests.
142 greptest "settimeout.js" "string timeout function timeout" 159 greptest "settimeout.js" "string timeout function timeout"
143 greptest "cleartimeout.js" "starting timeouts function timeout" 160 greptest "cleartimeout.js" "starting timeouts function timeout"
144 161
145 # Test the callback server; doesn't run as-is on chromeos. 162 # Test the callback server; doesn't run as-is on chromeos.
146 if [ "$CHROMEOS" != 1 ]; then 163 if [ "$CHROMEOS" != 1 ]; then
147 greptest "simple-shutdown.js" "LOOKS OK" 164 greptest "simple-shutdown.js" "LOOKS OK"
148 165
149 # Fire off this bg task to make an http request 166 # Fire off this bg task to make an http request
150 (sleep 2; \ 167 (sleep 2; \
(...skipping 11 matching lines...) Expand all
162 179
163 if [ $FAILURES -gt 0 ]; then 180 if [ $FAILURES -gt 0 ]; then
164 echo "TESTS FAILED: $FAILURES" 181 echo "TESTS FAILED: $FAILURES"
165 echo 182 echo
166 exit 1 183 exit 1
167 fi 184 fi
168 185
169 echo "All tests passed." 186 echo "All tests passed."
170 echo 187 echo
171 exit 0 188 exit 0
OLDNEW
« no previous file with comments | « pkcs11.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698