Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | #!/bin/bash |
michael@0 | 2 | # |
michael@0 | 3 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 6 | |
michael@0 | 7 | # |
michael@0 | 8 | # PRIOR TO RUNNING THIS SCRIPT |
michael@0 | 9 | # you should adjust MAIL_COMMAND and QA_LIST |
michael@0 | 10 | # |
michael@0 | 11 | # External dependencies: |
michael@0 | 12 | # - install the NISCC test files, e.g. at /niscc (readonly OK) |
michael@0 | 13 | # - libfaketimeMT because the test certificates have expired |
michael@0 | 14 | # - build environment for building NSS |
michael@0 | 15 | # - gdb to analyze core files |
michael@0 | 16 | # - a command line mail tool (e.g. mailx) |
michael@0 | 17 | # - openssl to combine input PEM files into pkcs#12 |
michael@0 | 18 | # - curl for obtaining version information from the web |
michael@0 | 19 | # |
michael@0 | 20 | |
michael@0 | 21 | ################################################################################ |
michael@0 | 22 | # Print script usage |
michael@0 | 23 | ################################################################################ |
michael@0 | 24 | usage() |
michael@0 | 25 | { |
michael@0 | 26 | cat << EOF |
michael@0 | 27 | Usage: $0 [options] |
michael@0 | 28 | |
michael@0 | 29 | Test NSS library against NISCC SMIME and TLS testcases. |
michael@0 | 30 | |
michael@0 | 31 | Options: |
michael@0 | 32 | -h, --help print this help message and exit |
michael@0 | 33 | -v, --verbose enable extra verbose output |
michael@0 | 34 | --niscc-home DIR use NISCC testcases from directory DIR (default /niscc) |
michael@0 | 35 | --host HOST use host HOST (default '127.0.0.1') |
michael@0 | 36 | --threads X set thread number to X (max. 10, default 10) |
michael@0 | 37 | --out DIR set DIR as output directory (default '/out') |
michael@0 | 38 | --mail ADDRESS send mail with test result to ADDRESS |
michael@0 | 39 | --nss DIR set NSS directory to DIR (default '~/niscc-hg/nss') |
michael@0 | 40 | --nss-hack DIR set hacked NSS directory to DIR (default '~/niscc-hg/nss_hack') |
michael@0 | 41 | --log-store store all the logs (only summary by default) |
michael@0 | 42 | --no-build-test don't pull and build tested NSS |
michael@0 | 43 | --no-build-hack don't pull and build hacked NSS |
michael@0 | 44 | --test-system test system installed NSS |
michael@0 | 45 | --date DATE use DATE in log archive name and outgoing email |
michael@0 | 46 | --libfaketime path.so use faketime library with LD_PRELOAD=path.so |
michael@0 | 47 | --smallset test only a very small subset |
michael@0 | 48 | |
michael@0 | 49 | All options are optional. |
michael@0 | 50 | All options (and possibly more) can be also set through environment variables. |
michael@0 | 51 | Commandline options have higher priority than environment variables. |
michael@0 | 52 | For more information please refer to the source code of this script. |
michael@0 | 53 | |
michael@0 | 54 | For a successfull run the script NEEDS the core file pattern to be 'core.*', |
michael@0 | 55 | e.g. 'core.%t'. You can check the current pattern in |
michael@0 | 56 | '/proc/sys/kernel/core_pattern'. Otherwise the test will be unable to detect |
michael@0 | 57 | any failures and will pass every time. |
michael@0 | 58 | |
michael@0 | 59 | It is recommended to use hacked and tested binaries in a location, where their |
michael@0 | 60 | absolute path is max. 80 characters. If their path is longer and a core file is |
michael@0 | 61 | generated, its properties may be incomplete. |
michael@0 | 62 | |
michael@0 | 63 | Return value of the script indicates how many failures it experienced. |
michael@0 | 64 | |
michael@0 | 65 | EOF |
michael@0 | 66 | exit $1 |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | ################################################################################ |
michael@0 | 70 | # Process command-line arguments |
michael@0 | 71 | ################################################################################ |
michael@0 | 72 | process_args() |
michael@0 | 73 | { |
michael@0 | 74 | HELP="false" |
michael@0 | 75 | args=`getopt -u -l "niscc-home:,host:,threads:,out:,verbose,mail:,nss:,nss-hack:,log-store,no-build-test,no-build-hack,help,test-system,date:,libfaketime:,smallset" -- "hv" $*` |
michael@0 | 76 | [ "$?" != "0" ] && usage 1 |
michael@0 | 77 | set -- $args |
michael@0 | 78 | for i; do |
michael@0 | 79 | case "$i" in |
michael@0 | 80 | -v|--verbose) |
michael@0 | 81 | shift |
michael@0 | 82 | VERBOSE="-v" |
michael@0 | 83 | ;; |
michael@0 | 84 | --niscc-home) |
michael@0 | 85 | shift |
michael@0 | 86 | NISCC_HOME="$1" |
michael@0 | 87 | shift |
michael@0 | 88 | ;; |
michael@0 | 89 | --host) |
michael@0 | 90 | shift |
michael@0 | 91 | HOST="$1" |
michael@0 | 92 | shift |
michael@0 | 93 | ;; |
michael@0 | 94 | --threads) |
michael@0 | 95 | shift |
michael@0 | 96 | THREADS="$1" |
michael@0 | 97 | shift |
michael@0 | 98 | ;; |
michael@0 | 99 | --out) |
michael@0 | 100 | shift |
michael@0 | 101 | TEST_OUTPUT="$1" |
michael@0 | 102 | shift |
michael@0 | 103 | ;; |
michael@0 | 104 | --mail) |
michael@0 | 105 | shift |
michael@0 | 106 | USE_MAIL="true" |
michael@0 | 107 | QA_LIST="$1" |
michael@0 | 108 | shift |
michael@0 | 109 | ;; |
michael@0 | 110 | --nss) |
michael@0 | 111 | shift |
michael@0 | 112 | LOCALDIST="$1" |
michael@0 | 113 | shift |
michael@0 | 114 | ;; |
michael@0 | 115 | --nss-hack) |
michael@0 | 116 | shift |
michael@0 | 117 | NSS_HACK="$1" |
michael@0 | 118 | shift |
michael@0 | 119 | ;; |
michael@0 | 120 | --log-store) |
michael@0 | 121 | shift |
michael@0 | 122 | LOG_STORE="true" |
michael@0 | 123 | ;; |
michael@0 | 124 | --no-build-test) |
michael@0 | 125 | shift |
michael@0 | 126 | NO_BUILD_TEST="true" |
michael@0 | 127 | ;; |
michael@0 | 128 | --no-build-hack) |
michael@0 | 129 | shift |
michael@0 | 130 | NO_BUILD_HACK="true" |
michael@0 | 131 | ;; |
michael@0 | 132 | -h|--help) |
michael@0 | 133 | shift |
michael@0 | 134 | HELP="true" |
michael@0 | 135 | ;; |
michael@0 | 136 | --test-system) |
michael@0 | 137 | shift |
michael@0 | 138 | TEST_SYSTEM="true" |
michael@0 | 139 | ;; |
michael@0 | 140 | --date) |
michael@0 | 141 | shift |
michael@0 | 142 | DATE="$1" |
michael@0 | 143 | shift |
michael@0 | 144 | ;; |
michael@0 | 145 | --libfaketime) |
michael@0 | 146 | shift |
michael@0 | 147 | FAKETIMELIB="$1" |
michael@0 | 148 | shift |
michael@0 | 149 | ;; |
michael@0 | 150 | --smallset) |
michael@0 | 151 | shift |
michael@0 | 152 | SMALLSET="true" |
michael@0 | 153 | ;; |
michael@0 | 154 | --) |
michael@0 | 155 | ;; |
michael@0 | 156 | *) |
michael@0 | 157 | ;; |
michael@0 | 158 | esac |
michael@0 | 159 | done |
michael@0 | 160 | [ $HELP = "true" ] && usage 0 |
michael@0 | 161 | } |
michael@0 | 162 | |
michael@0 | 163 | ################################################################################ |
michael@0 | 164 | # Create and set needed and useful environment variables |
michael@0 | 165 | ################################################################################ |
michael@0 | 166 | create_environment() |
michael@0 | 167 | { |
michael@0 | 168 | # Base location of NISCC testcases |
michael@0 | 169 | export NISCC_HOME=${NISCC_HOME:-/niscc} |
michael@0 | 170 | |
michael@0 | 171 | # Base location of NSS |
michael@0 | 172 | export HG=${HG:-"$HOME/niscc-hg"} |
michael@0 | 173 | |
michael@0 | 174 | # NSS being tested |
michael@0 | 175 | export LOCALDIST=${LOCALDIST:-"${HG}/nss"} |
michael@0 | 176 | |
michael@0 | 177 | # Hacked NSS - built with "NISCC_TEST=1" |
michael@0 | 178 | export NSS_HACK=${NSS_HACK:-"${HG}/nss_hack"} |
michael@0 | 179 | |
michael@0 | 180 | # Hostname of the testmachine |
michael@0 | 181 | export HOST=${HOST:-127.0.0.1} |
michael@0 | 182 | |
michael@0 | 183 | # Whether to store logfiles |
michael@0 | 184 | export LOG_STORE=${LOG_STORE:-"false"} |
michael@0 | 185 | |
michael@0 | 186 | # Whether to mail the summary |
michael@0 | 187 | export USE_MAIL=${USE_MAIL:-"false"} |
michael@0 | 188 | |
michael@0 | 189 | # How to mail summary |
michael@0 | 190 | export MAIL_COMMAND=${MAIL_COMMAND:-"mailx -S smtp=smtp://your.smtp.server:25 -r your+niscc@email.address"} |
michael@0 | 191 | |
michael@0 | 192 | # List of mail addresses where to send summary |
michael@0 | 193 | export QA_LIST=${QA_LIST:-"result@recipient.address"} |
michael@0 | 194 | |
michael@0 | 195 | # Whether to use 64b build |
michael@0 | 196 | export USE_64=${USE_64:-1} |
michael@0 | 197 | |
michael@0 | 198 | # Directory where to write all the output data (around 650MiB for each run) |
michael@0 | 199 | export TEST_OUTPUT=${TEST_OUTPUT:-"$HOME/out"} |
michael@0 | 200 | |
michael@0 | 201 | # How many threads to use in selfserv and strsclnt (max. 10) |
michael@0 | 202 | export THREADS=${THREADS:-10} |
michael@0 | 203 | |
michael@0 | 204 | # If true, do not build tthe tested version of NSS |
michael@0 | 205 | export NO_BUILD_TEST=${NO_BUILD_TEST:-"false"} |
michael@0 | 206 | |
michael@0 | 207 | # If true, do not build the special NSS version for NISCC |
michael@0 | 208 | export NO_BUILD_HACK=${NO_BUILD_HACK:-"false"} |
michael@0 | 209 | |
michael@0 | 210 | # If true, do not rebuild client and server directories |
michael@0 | 211 | export NO_SETUP=${NO_SETUP:-"false"} |
michael@0 | 212 | |
michael@0 | 213 | # Location of NISCC SSL/TLS testcases |
michael@0 | 214 | export TEST=${TEST:-"${NISCC_HOME}/NISCC_SSL_testcases"} |
michael@0 | 215 | |
michael@0 | 216 | # If true, then be extra verbose |
michael@0 | 217 | export VERBOSE=${VERBOSE:-""} |
michael@0 | 218 | |
michael@0 | 219 | # If true, test the system installed NSS |
michael@0 | 220 | export TEST_SYSTEM=${TEST_SYSTEM:-"false"} |
michael@0 | 221 | [ "$TEST_SYSTEM" = "true" ] && export NO_BUILD_TEST="true" |
michael@0 | 222 | |
michael@0 | 223 | [ ! -z "$VERBOSE" ] && set -xv |
michael@0 | 224 | |
michael@0 | 225 | # Real date for naming of archives (system date must be 2002-11-18 .. 2007-11-18 due to certificate validity |
michael@0 | 226 | DATE=${DATE:-`date`} |
michael@0 | 227 | export DATE=`date -d "$DATE" +%Y%m%d` |
michael@0 | 228 | |
michael@0 | 229 | FAKETIMELIB=${FAKETIMELIB:-""} |
michael@0 | 230 | export DATE=`date -d "$DATE" +%Y%m%d` |
michael@0 | 231 | |
michael@0 | 232 | # Whether to test only a very small subset |
michael@0 | 233 | export SMALLSET=${SMALLSET:-"false"} |
michael@0 | 234 | |
michael@0 | 235 | # Create output dir if it doesn't exist |
michael@0 | 236 | mkdir -p ${TEST_OUTPUT} |
michael@0 | 237 | } |
michael@0 | 238 | |
michael@0 | 239 | ################################################################################ |
michael@0 | 240 | # Do a HG pull of NSS |
michael@0 | 241 | ################################################################################ |
michael@0 | 242 | hg_pull() |
michael@0 | 243 | { |
michael@0 | 244 | # Tested NSS - by default using HG default tip |
michael@0 | 245 | if [ "$NO_BUILD_TEST" = "false" ]; then |
michael@0 | 246 | echo "cloning NSS sources to be tested from HG" |
michael@0 | 247 | [ ! -d "$LOCALDIST" ] && mkdir -p "$LOCALDIST" |
michael@0 | 248 | cd "$LOCALDIST" |
michael@0 | 249 | [ ! -d "$LOCALDIST/nspr" ] && hg clone --noupdate https://hg.mozilla.org/projects/nspr |
michael@0 | 250 | cd nspr; hg pull; hg update -C -r default; cd .. |
michael@0 | 251 | [ ! -d "$LOCALDIST/nss" ] && hg clone --noupdate https://hg.mozilla.org/projects/nss |
michael@0 | 252 | cd nss; hg pull; hg update -C -r default; cd .. |
michael@0 | 253 | #find . -exec touch {} \; |
michael@0 | 254 | fi |
michael@0 | 255 | |
michael@0 | 256 | # Hacked NSS - by default using some RTM version. |
michael@0 | 257 | # Do not use HEAD for hacked NSS - it needs to be stable and bug-free |
michael@0 | 258 | if [ "$NO_BUILD_HACK" = "false" ]; then |
michael@0 | 259 | echo "cloning NSS sources for a hacked build from HG" |
michael@0 | 260 | [ ! -d "$NSS_HACK" ] && mkdir -p "$NSS_HACK" |
michael@0 | 261 | cd "$NSS_HACK" |
michael@0 | 262 | NSPR_TAG=`curl --silent http://hg.mozilla.org/releases/mozilla-aurora/raw-file/default/nsprpub/TAG-INFO | head -1 | sed --regexp-extended 's/[[:space:]]//g' | awk '{print $1}'` |
michael@0 | 263 | NSS_TAG=`curl --silent http://hg.mozilla.org/releases/mozilla-aurora/raw-file/default/security/nss/TAG-INFO | head -1 | sed --regexp-extended 's/[[:space:]]//g' | awk '{print $1}'` |
michael@0 | 264 | [ ! -d "$NSS_HACK/nspr" ] && hg clone --noupdate https://hg.mozilla.org/projects/nspr |
michael@0 | 265 | cd nspr; hg pull; hg update -C -r "$NSPR_TAG"; cd .. |
michael@0 | 266 | [ ! -d "$NSS_HACK/nss" ] && hg clone --noupdate https://hg.mozilla.org/projects/nss |
michael@0 | 267 | cd nss; hg pull; hg update -C -r "$NSS_TAG"; cd .. |
michael@0 | 268 | #find . -exec touch {} \; |
michael@0 | 269 | fi |
michael@0 | 270 | } |
michael@0 | 271 | |
michael@0 | 272 | ################################################################################ |
michael@0 | 273 | # Build NSS after setting make variable NISCC_TEST |
michael@0 | 274 | ################################################################################ |
michael@0 | 275 | build_NSS() |
michael@0 | 276 | { |
michael@0 | 277 | # Tested NSS |
michael@0 | 278 | if [ "$NO_BUILD_TEST" = "false" ]; then |
michael@0 | 279 | echo "building NSS to be tested" |
michael@0 | 280 | cd "$LOCALDIST" |
michael@0 | 281 | unset NISCC_TEST |
michael@0 | 282 | cd nss |
michael@0 | 283 | gmake nss_clean_all &>> $TEST_OUTPUT/nisccBuildLog |
michael@0 | 284 | gmake nss_build_all &>> $TEST_OUTPUT/nisccBuildLog |
michael@0 | 285 | fi |
michael@0 | 286 | |
michael@0 | 287 | # Hacked NSS |
michael@0 | 288 | if [ "$NO_BUILD_HACK" = "false" ]; then |
michael@0 | 289 | echo "building hacked NSS" |
michael@0 | 290 | cd "$NSS_HACK" |
michael@0 | 291 | export NISCC_TEST=1 |
michael@0 | 292 | cd nss |
michael@0 | 293 | gmake nss_clean_all &>> $TEST_OUTPUT/nisccBuildLogHack |
michael@0 | 294 | gmake nss_build_all &>> $TEST_OUTPUT/nisccBuildLogHack |
michael@0 | 295 | fi |
michael@0 | 296 | |
michael@0 | 297 | unset NISCC_TEST |
michael@0 | 298 | } |
michael@0 | 299 | |
michael@0 | 300 | ################################################################################ |
michael@0 | 301 | # Set build dir, bin and lib directories |
michael@0 | 302 | ################################################################################ |
michael@0 | 303 | init() |
michael@0 | 304 | { |
michael@0 | 305 | # Enable useful core files to be generated in case of crash |
michael@0 | 306 | ulimit -c unlimited |
michael@0 | 307 | |
michael@0 | 308 | # Pattern of core files, they should be created in current directory |
michael@0 | 309 | echo "core_pattern $(cat /proc/sys/kernel/core_pattern)" > "$TEST_OUTPUT/nisccLog00" |
michael@0 | 310 | |
michael@0 | 311 | # gmake is needed in the path for this suite to run |
michael@0 | 312 | echo "PATH $PATH" >> "$TEST_OUTPUT/nisccLog00" |
michael@0 | 313 | |
michael@0 | 314 | # Find out hacked NSS version |
michael@0 | 315 | DISTTYPE=`cd "$NSS_HACK/nss/tests/common"; gmake objdir_name` |
michael@0 | 316 | echo "NSS_HACK DISTTYPE $DISTTYPE" >> "$TEST_OUTPUT/nisccLog00" |
michael@0 | 317 | export HACKBIN="$NSS_HACK/dist/$DISTTYPE/bin" |
michael@0 | 318 | export HACKLIB="$NSS_HACK/dist/$DISTTYPE/lib" |
michael@0 | 319 | |
michael@0 | 320 | if [ "$TEST_SYSTEM" = "false" ]; then |
michael@0 | 321 | # Find out nss version |
michael@0 | 322 | DISTTYPE=`cd "$LOCALDIST/nss/tests/common"; gmake objdir_name` |
michael@0 | 323 | echo "NSS DISTTYPE $DISTTYPE" >> "$TEST_OUTPUT/nisccLog00" |
michael@0 | 324 | export TESTBIN="$LOCALDIST/dist/$DISTTYPE/bin" |
michael@0 | 325 | export TESTLIB="$LOCALDIST/dist/$DISTTYPE/lib" |
michael@0 | 326 | export TESTTOOLS="$TESTBIN" |
michael@0 | 327 | else |
michael@0 | 328 | # Using system installed NSS |
michael@0 | 329 | echo "USING SYSTEM NSS" >> "$TEST_OUTPUT/nisccLog00" |
michael@0 | 330 | export TESTBIN="/usr/bin" |
michael@0 | 331 | if [ `uname -m` = "x86_64" ]; then |
michael@0 | 332 | export TESTLIB="/usr/lib64" |
michael@0 | 333 | export TESTTOOLS="/usr/lib64/nss/unsupported-tools" |
michael@0 | 334 | else |
michael@0 | 335 | export TESTLIB="/usr/lib" |
michael@0 | 336 | export TESTTOOLS="/usr/lib/nss/unsupported-tools" |
michael@0 | 337 | fi |
michael@0 | 338 | fi |
michael@0 | 339 | |
michael@0 | 340 | # Verify NISCC_TEST was set in the proper library |
michael@0 | 341 | if strings "$HACKLIB/libssl3.so" | grep NISCC_TEST > /dev/null 2>&1; then |
michael@0 | 342 | echo "$HACKLIB/libssl3.so contains NISCC_TEST" >> "$TEST_OUTPUT/nisccLog00" |
michael@0 | 343 | else |
michael@0 | 344 | echo "$HACKLIB/libssl3.so does NOT contain NISCC_TEST" >> "$TEST_OUTPUT/nisccLog00" |
michael@0 | 345 | fi |
michael@0 | 346 | |
michael@0 | 347 | if strings "$TESTLIB/libssl3.so" | grep NISCC_TEST > /dev/null 2>&1; then |
michael@0 | 348 | echo "$TESTLIB/libssl3.so contains NISCC_TEST" >> "$TEST_OUTPUT/nisccLog00" |
michael@0 | 349 | else |
michael@0 | 350 | echo "$TESTLIB/libssl3.so does NOT contain NISCC_TEST" >> "$TEST_OUTPUT/nisccLog00" |
michael@0 | 351 | fi |
michael@0 | 352 | } |
michael@0 | 353 | |
michael@0 | 354 | ################################################################################ |
michael@0 | 355 | # Setup simple client and server directory |
michael@0 | 356 | ################################################################################ |
michael@0 | 357 | ssl_setup_dirs_simple() |
michael@0 | 358 | { |
michael@0 | 359 | [ "$NO_SETUP" = "true" ] && return |
michael@0 | 360 | |
michael@0 | 361 | echo "Setting up working directories for SSL simple tests" |
michael@0 | 362 | |
michael@0 | 363 | CLIENT="$TEST_OUTPUT/niscc_ssl/simple_client" |
michael@0 | 364 | SERVER="$TEST_OUTPUT/niscc_ssl/simple_server" |
michael@0 | 365 | |
michael@0 | 366 | # Generate .p12 files |
michael@0 | 367 | openssl pkcs12 -export -inkey "$TEST/client_key.pem" -in "$TEST/client_crt.pem" -out "$TEST_OUTPUT/client_crt.p12" -passout pass:testtest1 -name "client_crt" |
michael@0 | 368 | openssl pkcs12 -export -inkey "$TEST/server_key.pem" -in "$TEST/server_crt.pem" -out "$TEST_OUTPUT/server_crt.p12" -passout pass:testtest1 -name "server_crt" |
michael@0 | 369 | |
michael@0 | 370 | # Setup simple client directory |
michael@0 | 371 | rm -rf "$CLIENT" |
michael@0 | 372 | mkdir -p "$CLIENT" |
michael@0 | 373 | echo test > "$CLIENT/password-is-test.txt" |
michael@0 | 374 | export LD_LIBRARY_PATH="$TESTLIB" |
michael@0 | 375 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 376 | "${TESTBIN}/certutil" -N -d "$CLIENT" -f "$CLIENT/password-is-test.txt" >> "$TEST_OUTPUT/nisccLog00" 2>&1 |
michael@0 | 377 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 378 | "${TESTBIN}/certutil" -A -d "$CLIENT" -n rootca -i "$TEST/rootca.crt" -t "C,C," >> "$TEST_OUTPUT/nisccLog00" 2>&1 |
michael@0 | 379 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 380 | "${TESTBIN}/pk12util" -i "$TEST_OUTPUT/client_crt.p12" -d "$CLIENT" -k "$CLIENT/password-is-test.txt" -W testtest1 >> "$TEST_OUTPUT/nisccLog00" 2>&1 |
michael@0 | 381 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 382 | "${TESTBIN}/certutil" -L -d "$CLIENT" >> "$TEST_OUTPUT/nisccLog00" 2>&1 |
michael@0 | 383 | |
michael@0 | 384 | # File containg message used for terminating the server |
michael@0 | 385 | echo "GET /stop HTTP/1.0" > "$CLIENT/stop.txt" |
michael@0 | 386 | echo "" >> "$CLIENT/stop.txt" |
michael@0 | 387 | |
michael@0 | 388 | # Setup simple server directory |
michael@0 | 389 | rm -rf "$SERVER" |
michael@0 | 390 | mkdir -p "$SERVER" |
michael@0 | 391 | echo test > "$SERVER/password-is-test.txt" |
michael@0 | 392 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 393 | "${TESTBIN}/certutil" -N -d "$SERVER" -f "$SERVER/password-is-test.txt" >> "$TEST_OUTPUT/nisccLog00" 2>&1 |
michael@0 | 394 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 395 | "${TESTBIN}/certutil" -A -d "$SERVER" -n rootca -i "$TEST/rootca.crt" -t "TC,C," >> "$TEST_OUTPUT/nisccLog00" 2>&1 |
michael@0 | 396 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 397 | "${TESTBIN}/pk12util" -i "$TEST_OUTPUT/server_crt.p12" -d "$SERVER" -k "$SERVER/password-is-test.txt" -W testtest1 >> "$TEST_OUTPUT/nisccLog00" 2>&1 |
michael@0 | 398 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 399 | "${TESTBIN}/certutil" -L -d "$SERVER" >> "$TEST_OUTPUT/nisccLog00" 2>&1 |
michael@0 | 400 | |
michael@0 | 401 | unset LD_LIBRARY_PATH |
michael@0 | 402 | } |
michael@0 | 403 | |
michael@0 | 404 | ################################################################################ |
michael@0 | 405 | # Setup resigned client and server directory |
michael@0 | 406 | ################################################################################ |
michael@0 | 407 | ssl_setup_dirs_resigned() |
michael@0 | 408 | { |
michael@0 | 409 | [ "$NO_SETUP" = "true" ] && return |
michael@0 | 410 | |
michael@0 | 411 | echo "Setting up working directories for SSL resigned tests" |
michael@0 | 412 | |
michael@0 | 413 | CLIENT="$TEST_OUTPUT/niscc_ssl/resigned_client" |
michael@0 | 414 | SERVER="$TEST_OUTPUT/niscc_ssl/resigned_server" |
michael@0 | 415 | |
michael@0 | 416 | # Setup resigned client directory |
michael@0 | 417 | rm -rf "$CLIENT" |
michael@0 | 418 | mkdir -p "$CLIENT" |
michael@0 | 419 | echo test > "$CLIENT/password-is-test.txt" |
michael@0 | 420 | export LD_LIBRARY_PATH="$TESTLIB" |
michael@0 | 421 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 422 | "${TESTBIN}/certutil" -N -d "$CLIENT" -f "$CLIENT/password-is-test.txt" >> "$TEST_OUTPUT/nisccLog00" 2>&1 |
michael@0 | 423 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 424 | "${TESTBIN}/certutil" -A -d "$CLIENT" -n rootca -i "$TEST/rootca.crt" -t "C,C," >> "$TEST_OUTPUT/nisccLog00" 2>&1 |
michael@0 | 425 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 426 | "${TESTBIN}/pk12util" -i "$TEST_OUTPUT/client_crt.p12" -d "$CLIENT" -k "$CLIENT/password-is-test.txt" -W testtest1 >> "$TEST_OUTPUT/nisccLog00" 2>&1 |
michael@0 | 427 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 428 | "${TESTBIN}/certutil" -L -d "$CLIENT" >> "$TEST_OUTPUT/nisccLog00" 2>&1 |
michael@0 | 429 | |
michael@0 | 430 | echo "GET /stop HTTP/1.0" > "$CLIENT/stop.txt" |
michael@0 | 431 | echo "" >> "$CLIENT/stop.txt" |
michael@0 | 432 | |
michael@0 | 433 | # Setup resigned server directory |
michael@0 | 434 | rm -rf "$SERVER" |
michael@0 | 435 | mkdir -p "$SERVER" |
michael@0 | 436 | echo test > "$SERVER/password-is-test.txt" |
michael@0 | 437 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 438 | "${TESTBIN}/certutil" -N -d "$SERVER" -f "$SERVER/password-is-test.txt" >> "$TEST_OUTPUT/nisccLog00" 2>&1 |
michael@0 | 439 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 440 | "${TESTBIN}/certutil" -A -d "$SERVER" -n rootca -i "$TEST/rootca.crt" -t "TC,C," >> "$TEST_OUTPUT/nisccLog00" 2>&1 |
michael@0 | 441 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 442 | "${TESTBIN}/pk12util" -i "$TEST_OUTPUT/server_crt.p12" -d "$SERVER" -k "$SERVER/password-is-test.txt" -W testtest1 >> "$TEST_OUTPUT/nisccLog00" 2>&1 |
michael@0 | 443 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 444 | "${TESTBIN}/certutil" -L -d "$SERVER" >> "$TEST_OUTPUT/nisccLog00" 2>&1 |
michael@0 | 445 | |
michael@0 | 446 | unset LD_LIBRARY_PATH |
michael@0 | 447 | } |
michael@0 | 448 | |
michael@0 | 449 | ################################################################################ |
michael@0 | 450 | # NISCC SMIME tests |
michael@0 | 451 | ################################################################################ |
michael@0 | 452 | niscc_smime() |
michael@0 | 453 | { |
michael@0 | 454 | cd "$TEST_OUTPUT" |
michael@0 | 455 | DATA="$NISCC_HOME/NISCC_SMIME_testcases" |
michael@0 | 456 | |
michael@0 | 457 | [ ! -d niscc_smime ] && mkdir -p niscc_smime |
michael@0 | 458 | |
michael@0 | 459 | export SMIME_CERT_DB_DIR=envDB |
michael@0 | 460 | export NSS_STRICT_SHUTDOWN=1 |
michael@0 | 461 | export NSS_DISABLE_ARENA_FREE_LIST=1 |
michael@0 | 462 | export LD_LIBRARY_PATH="$TESTLIB" |
michael@0 | 463 | |
michael@0 | 464 | # Generate .p12 files |
michael@0 | 465 | openssl pkcs12 -export -inkey "$DATA/Client.key" -in "$DATA/Client.crt" -out Client.p12 -passout pass:testtest1 &>/dev/null |
michael@0 | 466 | openssl pkcs12 -export -inkey "$DATA/CA.key" -in "$DATA/CA.crt" -out CA.p12 -passout pass:testtest1 &>/dev/null |
michael@0 | 467 | |
michael@0 | 468 | # Generate envDB if needed |
michael@0 | 469 | if [ ! -d "$SMIME_CERT_DB_DIR" ]; then |
michael@0 | 470 | mkdir -p "$SMIME_CERT_DB_DIR" |
michael@0 | 471 | echo testtest1 > password-is-testtest1.txt |
michael@0 | 472 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 473 | "${TESTBIN}/certutil" -N -d "./$SMIME_CERT_DB_DIR" -f password-is-testtest1.txt > /dev/null 2>&1 |
michael@0 | 474 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 475 | "${TESTBIN}/certutil" -A -d "$SMIME_CERT_DB_DIR" -f password-is-testtest1.txt -i "$DATA/CA.crt" -n CA -t "TC,C," |
michael@0 | 476 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 477 | "${TESTBIN}/certutil" -A -d "$SMIME_CERT_DB_DIR" -f password-is-testtest1.txt -i "$DATA/Client.crt" -n Client -t "TC,C," |
michael@0 | 478 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 479 | "${TESTBIN}/pk12util" -i ./CA.p12 -d "$SMIME_CERT_DB_DIR" -k password-is-testtest1.txt -W testtest1 |
michael@0 | 480 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 481 | "${TESTBIN}/pk12util" -i ./Client.p12 -d "$SMIME_CERT_DB_DIR" -k password-is-testtest1.txt -W testtest1 |
michael@0 | 482 | fi |
michael@0 | 483 | |
michael@0 | 484 | # if p7m-ed-m-files.txt does not exist, then generate it. |
michael@0 | 485 | [ -f "$DATA/p7m-ed-m-files.txt" ] && sed "s|^|$DATA/|" "$DATA/p7m-ed-m-files.txt" > p7m-ed-m-files.txt |
michael@0 | 486 | export P7M_ED_M_FILES=p7m-ed-m-files.txt |
michael@0 | 487 | if [ "$SMALLSET" = "true" ]; then |
michael@0 | 488 | [ ! -f "$P7M_ED_M_FILES" ] && find "$DATA"/p7m-ed-m-0* -type f -print | head -10 >> "$P7M_ED_M_FILES" |
michael@0 | 489 | else |
michael@0 | 490 | [ ! -f "$P7M_ED_M_FILES" ] && find "$DATA"/p7m-ed-m-0* -type f -print >> "$P7M_ED_M_FILES" |
michael@0 | 491 | fi |
michael@0 | 492 | |
michael@0 | 493 | # Test "p7m-ed-m*" testcases |
michael@0 | 494 | echo "Testing SMIME enveloped data testcases" |
michael@0 | 495 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 496 | "${TESTBIN}/cmsutil" $VERBOSE -D -d "$SMIME_CERT_DB_DIR" -p testtest1 -b -i "$P7M_ED_M_FILES" > niscc_smime/p7m-ed-m-results.txt 2>&1 |
michael@0 | 497 | |
michael@0 | 498 | export SMIME_CERT_DB_DIR=sigDB |
michael@0 | 499 | # Generate sigDB if needed |
michael@0 | 500 | if [ ! -d "$SMIME_CERT_DB_DIR" ]; then |
michael@0 | 501 | mkdir -p "$SMIME_CERT_DB_DIR" |
michael@0 | 502 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 503 | "${TESTBIN}/certutil" -N -d "$SMIME_CERT_DB_DIR" -f password-is-testtest1.txt |
michael@0 | 504 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 505 | "${TESTBIN}/certutil" -A -d "$SMIME_CERT_DB_DIR" -i "$DATA/CA.crt" -n CA -t "TC,C," |
michael@0 | 506 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 507 | "${TESTBIN}/certutil" -A -d "$SMIME_CERT_DB_DIR" -i "$DATA/Client.crt" -n Client -t "TC,C," |
michael@0 | 508 | fi |
michael@0 | 509 | |
michael@0 | 510 | # if p7m-sd-dt-files.txt does not exist, then generate it. |
michael@0 | 511 | [ -f "$DATA/p7m-sd-dt-files.txt" ] && sed "s|^|$DATA/|" "$DATA/p7m-sd-dt-files.txt" > p7m-sd-dt-files.txt |
michael@0 | 512 | export P7M_SD_DT_FILES=p7m-sd-dt-files.txt |
michael@0 | 513 | if [ "$SMALLSET" = "true" ]; then |
michael@0 | 514 | [ ! -f "$P7M_SD_DT_FILES" ] && find "$DATA"/p7m-sd-dt-[cm]-* -type f -print | head -10 >> "$P7M_SD_DT_FILES" |
michael@0 | 515 | else |
michael@0 | 516 | [ ! -f "$P7M_SD_DT_FILES" ] && find "$DATA"/p7m-sd-dt-[cm]-* -type f -print >> "$P7M_SD_DT_FILES" |
michael@0 | 517 | fi |
michael@0 | 518 | |
michael@0 | 519 | [ ! -f detached.txt ] && touch detached.txt |
michael@0 | 520 | |
michael@0 | 521 | # Test "p7m-sd-dt*" testcases |
michael@0 | 522 | echo "Testing SMIME detached signed data testcases" |
michael@0 | 523 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 524 | "${TESTBIN}/cmsutil" $VERBOSE -D -d "$SMIME_CERT_DB_DIR" -c detached.txt -b -i "$P7M_SD_DT_FILES" > niscc_smime/p7m-sd-dt-results.txt 2>&1 |
michael@0 | 525 | |
michael@0 | 526 | # if p7m-sd-op-files.txt does not exist, then generate it. |
michael@0 | 527 | [ -f "$DATA/p7m-sd-op-files.txt" ] && sed "s|^|$DATA/|" "$DATA/p7m-sd-op-files.txt" > p7m-sd-op-files.txt |
michael@0 | 528 | export P7M_SD_OP_FILES=p7m-sd-op-files.txt |
michael@0 | 529 | if [ "$SMALLSET" = "true" ]; then |
michael@0 | 530 | [ ! -f "$P7M_SD_OP_FILES" ] && find "$DATA"/p7m-sd-op-[cm]-* -type f -print | head -10 >> "$P7M_SD_OP_FILES" |
michael@0 | 531 | else |
michael@0 | 532 | [ ! -f "$P7M_SD_OP_FILES" ] && find "$DATA"/p7m-sd-op-[cm]-* -type f -print >> "$P7M_SD_OP_FILES" |
michael@0 | 533 | fi |
michael@0 | 534 | |
michael@0 | 535 | # Test "p7m-sd-op*" testcases |
michael@0 | 536 | echo "Testing SMIME opaque signed data testcases" |
michael@0 | 537 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 538 | "${TESTBIN}/cmsutil" $VERBOSE -D -d "$SMIME_CERT_DB_DIR" -b -i "$P7M_SD_OP_FILES" > niscc_smime/p7m-sd-op-results.txt 2>&1 |
michael@0 | 539 | |
michael@0 | 540 | unset LD_LIBRARY_PATH |
michael@0 | 541 | } |
michael@0 | 542 | |
michael@0 | 543 | ################################################################################ |
michael@0 | 544 | # Set env variables for NISCC SSL tests |
michael@0 | 545 | ################################################################################ |
michael@0 | 546 | niscc_ssl_init() |
michael@0 | 547 | { |
michael@0 | 548 | export NSS_STRICT_SHUTDOWN=1 |
michael@0 | 549 | export NSS_DISABLE_ARENA_FREE_LIST=1 |
michael@0 | 550 | cd "$TEST_OUTPUT" |
michael@0 | 551 | } |
michael@0 | 552 | |
michael@0 | 553 | force_crash() |
michael@0 | 554 | { |
michael@0 | 555 | echo "int main(int argc, char *argv[]) { int *i; i = (int*)(void*)1; *i = 1; }" > "$TEST_OUTPUT/crashme.c" |
michael@0 | 556 | gcc -g -o "$TEST_OUTPUT/crashme" "$TEST_OUTPUT/crashme.c" |
michael@0 | 557 | "$TEST_OUTPUT/crashme" |
michael@0 | 558 | } |
michael@0 | 559 | |
michael@0 | 560 | ################################################################################ |
michael@0 | 561 | # Do simple client auth tests |
michael@0 | 562 | # Use an altered client against the server |
michael@0 | 563 | ################################################################################ |
michael@0 | 564 | ssl_simple_client_auth() |
michael@0 | 565 | { |
michael@0 | 566 | echo "Testing SSL simple client auth testcases" |
michael@0 | 567 | export CLIENT="$TEST_OUTPUT/niscc_ssl/simple_client" |
michael@0 | 568 | export SERVER="$TEST_OUTPUT/niscc_ssl/simple_server" |
michael@0 | 569 | export PORT=8443 |
michael@0 | 570 | export START_AT=1 |
michael@0 | 571 | if [ "$SMALLSET" = "true" ]; then |
michael@0 | 572 | export STOP_AT=10 |
michael@0 | 573 | else |
michael@0 | 574 | export STOP_AT=106160 |
michael@0 | 575 | fi |
michael@0 | 576 | unset NISCC_TEST |
michael@0 | 577 | export LD_LIBRARY_PATH="$TESTLIB" |
michael@0 | 578 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 579 | "${TESTTOOLS}/selfserv" $VERBOSE -p $PORT -d "$SERVER" -n server_crt -rr -t $THREADS -w test > "$TEST_OUTPUT/nisccLog01" 2>&1 & |
michael@0 | 580 | |
michael@0 | 581 | export NISCC_TEST="$TEST/simple_client" |
michael@0 | 582 | export LD_LIBRARY_PATH="$HACKLIB" |
michael@0 | 583 | |
michael@0 | 584 | for START in `seq $START_AT $THREADS $STOP_AT`; do |
michael@0 | 585 | START_AT=$START \ |
michael@0 | 586 | STOP_AT=$(($START+$THREADS)) \ |
michael@0 | 587 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 588 | "${HACKBIN}/strsclnt" $VERBOSE -d "$CLIENT" -n client_crt -p $PORT -t $THREADS -c $THREADS -o -N -w test $HOST >> "$TEST_OUTPUT/nisccLog02" 2>&1 |
michael@0 | 589 | done |
michael@0 | 590 | |
michael@0 | 591 | unset NISCC_TEST |
michael@0 | 592 | echo "starting tstclnt to shutdown simple client selfserv process" |
michael@0 | 593 | for i in `seq 5`; do |
michael@0 | 594 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 595 | "${HACKBIN}/tstclnt" -h $HOST -p $PORT -d "$CLIENT" -n client_crt -o -f -w test < "$CLIENT/stop.txt" >> "$TEST_OUTPUT/nisccLog02" 2>&1 |
michael@0 | 596 | done |
michael@0 | 597 | |
michael@0 | 598 | unset LD_LIBRARY_PATH |
michael@0 | 599 | |
michael@0 | 600 | sleep 1 |
michael@0 | 601 | } |
michael@0 | 602 | |
michael@0 | 603 | ################################################################################ |
michael@0 | 604 | # Do simple server auth tests |
michael@0 | 605 | # Use an altered server against the client |
michael@0 | 606 | ################################################################################ |
michael@0 | 607 | ssl_simple_server_auth() |
michael@0 | 608 | { |
michael@0 | 609 | echo "Testing SSL simple server auth testcases" |
michael@0 | 610 | export CLIENT="$TEST_OUTPUT/niscc_ssl/simple_client" |
michael@0 | 611 | export SERVER="$TEST_OUTPUT/niscc_ssl/simple_server" |
michael@0 | 612 | export PORT=8444 |
michael@0 | 613 | export START_AT=00000001 |
michael@0 | 614 | if [ "$SMALLSET" = "true" ]; then |
michael@0 | 615 | export STOP_AT=00000010 |
michael@0 | 616 | else |
michael@0 | 617 | export STOP_AT=00106167 |
michael@0 | 618 | fi |
michael@0 | 619 | export LD_LIBRARY_PATH="$HACKLIB" |
michael@0 | 620 | export NISCC_TEST="$TEST/simple_server" |
michael@0 | 621 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 622 | "${HACKBIN}/selfserv" $VERBOSE -p $PORT -d "$SERVER" -n server_crt -t $THREADS -w test > "$TEST_OUTPUT/nisccLog03" 2>&1 & |
michael@0 | 623 | |
michael@0 | 624 | unset NISCC_TEST |
michael@0 | 625 | export LD_LIBRARY_PATH="$TESTLIB" |
michael@0 | 626 | for START in `seq $START_AT $THREADS $STOP_AT`; do |
michael@0 | 627 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 628 | "${TESTTOOLS}/strsclnt" $VERBOSE -d "$CLIENT" -p $PORT -t $THREADS -c $THREADS -o -N $HOST >> "$TEST_OUTPUT/nisccLog04" 2>&1 |
michael@0 | 629 | done |
michael@0 | 630 | |
michael@0 | 631 | echo "starting tstclnt to shutdown simple server selfserv process" |
michael@0 | 632 | for i in `seq 5`; do |
michael@0 | 633 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 634 | "${TESTTOOLS}/tstclnt" -h $HOST -p $PORT -d "$CLIENT" -n client_crt -o -f -w test < "$CLIENT/stop.txt" >> "$TEST_OUTPUT/nisccLog04" 2>&1 |
michael@0 | 635 | done |
michael@0 | 636 | |
michael@0 | 637 | unset LD_LIBRARY_PATH |
michael@0 | 638 | |
michael@0 | 639 | sleep 1 |
michael@0 | 640 | } |
michael@0 | 641 | |
michael@0 | 642 | ################################################################################ |
michael@0 | 643 | # Do simple rootCA tests |
michael@0 | 644 | # Use an altered server against the client |
michael@0 | 645 | ################################################################################ |
michael@0 | 646 | ssl_simple_rootca() |
michael@0 | 647 | { |
michael@0 | 648 | echo "Testing SSL simple rootCA testcases" |
michael@0 | 649 | export CLIENT="$TEST_OUTPUT/niscc_ssl/simple_client" |
michael@0 | 650 | export SERVER="$TEST_OUTPUT/niscc_ssl/simple_server" |
michael@0 | 651 | export PORT=8445 |
michael@0 | 652 | export START_AT=1 |
michael@0 | 653 | if [ "$SMALLSET" = "true" ]; then |
michael@0 | 654 | export STOP_AT=10 |
michael@0 | 655 | else |
michael@0 | 656 | export STOP_AT=106190 |
michael@0 | 657 | fi |
michael@0 | 658 | export LD_LIBRARY_PATH="$HACKLIB" |
michael@0 | 659 | export NISCC_TEST="$TEST/simple_rootca" |
michael@0 | 660 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 661 | "${HACKBIN}/selfserv" $VERBOSE -p $PORT -d "$SERVER" -n server_crt -t $THREADS -w test > "$TEST_OUTPUT/nisccLog05" 2>&1 & |
michael@0 | 662 | |
michael@0 | 663 | unset NISCC_TEST |
michael@0 | 664 | export LD_LIBRARY_PATH="$TESTLIB" |
michael@0 | 665 | for START in `seq $START_AT $THREADS $STOP_AT`; do |
michael@0 | 666 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 667 | "${TESTTOOLS}/strsclnt" $VERBOSE -d "$CLIENT" -p $PORT -t $THREADS -c $THREADS -o -N $HOST >> "$TEST_OUTPUT/nisccLog06" 2>&1 |
michael@0 | 668 | done |
michael@0 | 669 | |
michael@0 | 670 | echo "starting tstclnt to shutdown simple rootca selfserv process" |
michael@0 | 671 | for i in `seq 5`; do |
michael@0 | 672 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 673 | "${TESTTOOLS}/tstclnt" -h $HOST -p $PORT -d "$CLIENT" -n client_crt -o -f -w test < "$CLIENT/stop.txt" >> "$TEST_OUTPUT/nisccLog06" 2>&1 |
michael@0 | 674 | done |
michael@0 | 675 | |
michael@0 | 676 | unset LD_LIBRARY_PATH |
michael@0 | 677 | |
michael@0 | 678 | sleep 1 |
michael@0 | 679 | } |
michael@0 | 680 | |
michael@0 | 681 | ################################################################################ |
michael@0 | 682 | # Do resigned client auth tests |
michael@0 | 683 | # Use an altered client against the server |
michael@0 | 684 | ################################################################################ |
michael@0 | 685 | ssl_resigned_client_auth() |
michael@0 | 686 | { |
michael@0 | 687 | echo "Testing SSL resigned client auth testcases" |
michael@0 | 688 | export CLIENT="$TEST_OUTPUT/niscc_ssl/resigned_client" |
michael@0 | 689 | export SERVER="$TEST_OUTPUT/niscc_ssl/resigned_server" |
michael@0 | 690 | export PORT=8446 |
michael@0 | 691 | export START_AT=0 |
michael@0 | 692 | if [ "$SMALLSET" = "true" ]; then |
michael@0 | 693 | export STOP_AT=9 |
michael@0 | 694 | else |
michael@0 | 695 | export STOP_AT=99981 |
michael@0 | 696 | fi |
michael@0 | 697 | unset NISCC_TEST |
michael@0 | 698 | export LD_LIBRARY_PATH="$TESTLIB" |
michael@0 | 699 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 700 | "${TESTTOOLS}/selfserv" $VERBOSE -p $PORT -d "$SERVER" -n server_crt -rr -t $THREADS -w test > "$TEST_OUTPUT/nisccLog07" 2>&1 & |
michael@0 | 701 | |
michael@0 | 702 | export NISCC_TEST="$TEST/resigned_client" |
michael@0 | 703 | export LD_LIBRARY_PATH="$HACKLIB" |
michael@0 | 704 | |
michael@0 | 705 | for START in `seq $START_AT $THREADS $STOP_AT`; do |
michael@0 | 706 | START_AT=$START \ |
michael@0 | 707 | STOP_AT=$(($START+$THREADS)) \ |
michael@0 | 708 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 709 | "${HACKBIN}/strsclnt" $VERBOSE -d "$CLIENT" -n client_crt -p $PORT -t $THREADS -c $THREADS -o -N -w test $HOST >> "$TEST_OUTPUT/nisccLog08" 2>&1 |
michael@0 | 710 | done |
michael@0 | 711 | |
michael@0 | 712 | unset NISCC_TEST |
michael@0 | 713 | echo "starting tstclnt to shutdown resigned client selfserv process" |
michael@0 | 714 | for i in `seq 5`; do |
michael@0 | 715 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 716 | "${HACKBIN}/tstclnt" -h $HOST -p $PORT -d "$CLIENT" -n client_crt -o -f -w test < "$CLIENT/stop.txt" >> "$TEST_OUTPUT/nisccLog08" 2>&1 |
michael@0 | 717 | done |
michael@0 | 718 | |
michael@0 | 719 | unset LD_LIBRARY_PATH |
michael@0 | 720 | |
michael@0 | 721 | sleep 1 |
michael@0 | 722 | } |
michael@0 | 723 | |
michael@0 | 724 | ################################################################################ |
michael@0 | 725 | # Do resigned server auth tests |
michael@0 | 726 | # Use an altered server against the client |
michael@0 | 727 | ################################################################################ |
michael@0 | 728 | ssl_resigned_server_auth() |
michael@0 | 729 | { |
michael@0 | 730 | echo "Testing SSL resigned server auth testcases" |
michael@0 | 731 | export CLIENT="$TEST_OUTPUT/niscc_ssl/resigned_client" |
michael@0 | 732 | export SERVER="$TEST_OUTPUT/niscc_ssl/resigned_server" |
michael@0 | 733 | export PORT=8447 |
michael@0 | 734 | export START_AT=0 |
michael@0 | 735 | if [ "$SMALLSET" = "true" ]; then |
michael@0 | 736 | export STOP_AT=9 |
michael@0 | 737 | else |
michael@0 | 738 | export STOP_AT=100068 |
michael@0 | 739 | fi |
michael@0 | 740 | export LD_LIBRARY_PATH="$HACKLIB" |
michael@0 | 741 | export NISCC_TEST="$TEST/resigned_server" |
michael@0 | 742 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 743 | "${HACKBIN}/selfserv" $VERBOSE -p $PORT -d "$SERVER" -n server_crt -t $THREADS -w test > "$TEST_OUTPUT/nisccLog09" 2>&1 & |
michael@0 | 744 | |
michael@0 | 745 | unset NISCC_TEST |
michael@0 | 746 | export LD_LIBRARY_PATH="$TESTLIB" |
michael@0 | 747 | for START in `seq $START_AT $THREADS $STOP_AT`; do |
michael@0 | 748 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 749 | "${TESTTOOLS}/strsclnt" $VERBOSE -d "$CLIENT" -p $PORT -t $THREADS -c $THREADS -o -N $HOST >> "$TEST_OUTPUT/nisccLog10" 2>&1 |
michael@0 | 750 | done |
michael@0 | 751 | |
michael@0 | 752 | echo "starting tstclnt to shutdown resigned server selfserv process" |
michael@0 | 753 | for i in `seq 5`; do |
michael@0 | 754 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 755 | "${TESTTOOLS}/tstclnt" -h $HOST -p $PORT -d "$CLIENT" -n client_crt -o -f -w test < "$CLIENT/stop.txt" >> "$TEST_OUTPUT/nisccLog10" 2>&1 |
michael@0 | 756 | done |
michael@0 | 757 | |
michael@0 | 758 | unset LD_LIBRARY_PATH |
michael@0 | 759 | |
michael@0 | 760 | sleep 1 |
michael@0 | 761 | } |
michael@0 | 762 | |
michael@0 | 763 | ################################################################################ |
michael@0 | 764 | # Do resigned rootCA tests |
michael@0 | 765 | # Use an altered server against the client |
michael@0 | 766 | ################################################################################ |
michael@0 | 767 | ssl_resigned_rootca() |
michael@0 | 768 | { |
michael@0 | 769 | echo "Testing SSL resigned rootCA testcases" |
michael@0 | 770 | export CLIENT="$TEST_OUTPUT/niscc_ssl/resigned_client" |
michael@0 | 771 | export SERVER="$TEST_OUTPUT/niscc_ssl/resigned_server" |
michael@0 | 772 | export PORT=8448 |
michael@0 | 773 | export START_AT=0 |
michael@0 | 774 | if [ "$SMALLSET" = "true" ]; then |
michael@0 | 775 | export STOP_AT=9 |
michael@0 | 776 | else |
michael@0 | 777 | export STOP_AT=99959 |
michael@0 | 778 | fi |
michael@0 | 779 | export LD_LIBRARY_PATH="$HACKLIB" |
michael@0 | 780 | export NISCC_TEST="$TEST/resigned_rootca" |
michael@0 | 781 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 782 | "${HACKBIN}/selfserv" $VERBOSE -p $PORT -d "$SERVER" -n server_crt -t $THREADS -w test > "$TEST_OUTPUT/nisccLog11" 2>&1 & |
michael@0 | 783 | |
michael@0 | 784 | unset NISCC_TEST |
michael@0 | 785 | export LD_LIBRARY_PATH="$TESTLIB" |
michael@0 | 786 | for START in `seq $START_AT $THREADS $STOP_AT`; do |
michael@0 | 787 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 788 | "${TESTTOOLS}/strsclnt" $VERBOSE -d "$CLIENT" -p $PORT -t $THREADS -c $THREADS -o -N $HOST >> "$TEST_OUTPUT/nisccLog12" 2>&1 |
michael@0 | 789 | done |
michael@0 | 790 | |
michael@0 | 791 | echo "starting tstclnt to shutdown resigned rootca selfserv process" |
michael@0 | 792 | for i in `seq 5`; do |
michael@0 | 793 | LD_PRELOAD=${FAKETIMELIB} NO_FAKE_STAT=1 FAKETIME="@2004-03-29 14:14:14" \ |
michael@0 | 794 | "${TESTTOOLS}/tstclnt" -h $HOST -p $PORT -d "$CLIENT" -n client_crt -o -f -w test < "$CLIENT/stop.txt" >> "$TEST_OUTPUT/nisccLog12" 2>&1 |
michael@0 | 795 | done |
michael@0 | 796 | |
michael@0 | 797 | unset LD_LIBRARY_PATH |
michael@0 | 798 | |
michael@0 | 799 | sleep 1 |
michael@0 | 800 | } |
michael@0 | 801 | |
michael@0 | 802 | ################################################################################ |
michael@0 | 803 | # Email the test logfile, and if core found, notify of failure |
michael@0 | 804 | ################################################################################ |
michael@0 | 805 | mail_testLog() |
michael@0 | 806 | { |
michael@0 | 807 | pushd "$TEST_OUTPUT" |
michael@0 | 808 | |
michael@0 | 809 | # remove mozilla nss build false positives and core stored in previous runs |
michael@0 | 810 | find . -name "core*" -print | grep -v coreconf | grep -v core_watch | grep -v archive >> crashLog |
michael@0 | 811 | export SIZE=`cat crashLog | wc -l` |
michael@0 | 812 | |
michael@0 | 813 | [ "$USE_MAIL" = "false" ] && return |
michael@0 | 814 | |
michael@0 | 815 | # mail text |
michael@0 | 816 | MT=mailText |
michael@0 | 817 | rm -f $MT |
michael@0 | 818 | |
michael@0 | 819 | if [ "$SIZE" -ne 1 ]; then |
michael@0 | 820 | echo "### FAILED ###" >> $MT |
michael@0 | 821 | echo "### Exactly one crash is expected." >> $MT |
michael@0 | 822 | echo "### Zero means: crash detection is broken, fix the script!" >> $MT |
michael@0 | 823 | echo "### > 1 means: robustness test failure, fix the bug! (check the logs)" >> $MT |
michael@0 | 824 | cat crashLog >> nisccLogSummary |
michael@0 | 825 | SUBJ="FAILED: NISCC TESTS (check file: crashLog)" |
michael@0 | 826 | else |
michael@0 | 827 | echo ":) PASSED :)" >> $MT |
michael@0 | 828 | SUBJ="PASSED: NISCC tests" |
michael@0 | 829 | fi |
michael@0 | 830 | |
michael@0 | 831 | echo "Date used during test run: $DATE" >> $MT |
michael@0 | 832 | |
michael@0 | 833 | echo "Count of lines in files:" >> $MT |
michael@0 | 834 | wc -l crashLog nisccBuildLog nisccBuildLogHack nisccLog[0-9]* p7m-* |grep -vw total >> $MT |
michael@0 | 835 | NUM=`cat nisccLog0[123456789] nisccLog1[12] | egrep -ic "success/passed"` |
michael@0 | 836 | echo "Number of times the SSL tests reported success/passed (low expected): $NUM" >> $MT |
michael@0 | 837 | NUM=`cat nisccLog0[123456789] nisccLog1[12] | egrep -ic "problem|failed|error"` |
michael@0 | 838 | echo "Number of times the SSL tests reported problem/failed/error (high expected): $NUM" >> $MT |
michael@0 | 839 | NUM=`cat niscc_smime/p7m*results.txt | egrep -ic "success/passed"` |
michael@0 | 840 | echo "Number of times the S/MIME tests reported success/passed (low expected): $NUM" >> $MT |
michael@0 | 841 | NUM=`cat niscc_smime/p7m*results.txt | egrep -ic "problem|failed|error"` |
michael@0 | 842 | echo "Number of times the S/MIME tests reported problem/failed/error (high expected): $NUM" >> $MT |
michael@0 | 843 | echo "==== tail of nisccBuildLog ====" >> $MT |
michael@0 | 844 | tail -20 nisccBuildLog >> $MT |
michael@0 | 845 | echo "===============================" >> $MT |
michael@0 | 846 | echo "==== tail of nisccBuildLogHack ====" >> $MT |
michael@0 | 847 | tail -20 nisccBuildLogHack >> $MT |
michael@0 | 848 | echo "===================================" >> $MT |
michael@0 | 849 | |
michael@0 | 850 | #NUM=`` |
michael@0 | 851 | #echo "Number of : $NUM" >> $MT |
michael@0 | 852 | |
michael@0 | 853 | cat $MT | $MAIL_COMMAND -s "$SUBJ" $QA_LIST |
michael@0 | 854 | |
michael@0 | 855 | popd |
michael@0 | 856 | } |
michael@0 | 857 | |
michael@0 | 858 | ################################################################################ |
michael@0 | 859 | # Summarize all logs |
michael@0 | 860 | ################################################################################ |
michael@0 | 861 | log_summary() |
michael@0 | 862 | { |
michael@0 | 863 | echo "Summarizing all logs" |
michael@0 | 864 | # Move old logs |
michael@0 | 865 | [ -f "$TEST_OUTPUT/nisccLogSummary" ] && mv nisccLogSummary nisccLogSummary.old |
michael@0 | 866 | [ -f "$TEST_OUTPUT/crashLog" ] && mv crashLog crashLog.old |
michael@0 | 867 | |
michael@0 | 868 | for a in $TEST_OUTPUT/nisccLog[0-9]*; do |
michael@0 | 869 | echo ================================== "$a" |
michael@0 | 870 | grep -v using "$a" | sort | uniq -c | sort -b -n +0 -1 |
michael@0 | 871 | done > $TEST_OUTPUT/nisccLogSummary |
michael@0 | 872 | |
michael@0 | 873 | for a in $TEST_OUTPUT/niscc_smime/p7m-*-results.txt; do |
michael@0 | 874 | echo ================================== "$a" |
michael@0 | 875 | grep -v using "$a" | sort | uniq -c | sort -b -n +0 -1 |
michael@0 | 876 | done >> $TEST_OUTPUT/nisccLogSummary |
michael@0 | 877 | } |
michael@0 | 878 | |
michael@0 | 879 | ################################################################################ |
michael@0 | 880 | # Process core files |
michael@0 | 881 | ################################################################################ |
michael@0 | 882 | core_process() |
michael@0 | 883 | { |
michael@0 | 884 | echo "Processing core files" |
michael@0 | 885 | cd "$TEST_OUTPUT" |
michael@0 | 886 | |
michael@0 | 887 | for CORE in `cat crashLog`; do |
michael@0 | 888 | FILE=`file "$CORE" | sed "s/.* from '//" | sed "s/'.*//"` |
michael@0 | 889 | BINARY=`strings "$CORE" | grep "^${FILE}" | tail -1` |
michael@0 | 890 | gdb "$BINARY" "$CORE" << EOF_GDB > "$CORE.details" |
michael@0 | 891 | where |
michael@0 | 892 | quit |
michael@0 | 893 | EOF_GDB |
michael@0 | 894 | done |
michael@0 | 895 | } |
michael@0 | 896 | |
michael@0 | 897 | ################################################################################ |
michael@0 | 898 | # Move the old log files to save them, delete extra log files |
michael@0 | 899 | ################################################################################ |
michael@0 | 900 | move_files() |
michael@0 | 901 | { |
michael@0 | 902 | echo "Moving and deleting log files" |
michael@0 | 903 | cd "$TEST_OUTPUT" |
michael@0 | 904 | |
michael@0 | 905 | rm -rf TRASH |
michael@0 | 906 | mkdir TRASH |
michael@0 | 907 | |
michael@0 | 908 | if [ "$LOG_STORE" = "true" ]; then |
michael@0 | 909 | BRANCH=`echo $LOCALDIST | sed "s:.*/\(security.*\)/builds/.*:\1:"` |
michael@0 | 910 | if [ "$BRANCH" = "$LOCALDIST" ]; then |
michael@0 | 911 | ARCHIVE="$TEST_OUTPUT/archive" |
michael@0 | 912 | else |
michael@0 | 913 | ARCHIVE="$TEST_OUTPUT/archive/$BRANCH" |
michael@0 | 914 | fi |
michael@0 | 915 | |
michael@0 | 916 | # Check for archive directory |
michael@0 | 917 | if [ ! -d "$ARCHIVE" ]; then |
michael@0 | 918 | mkdir -p "$ARCHIVE" |
michael@0 | 919 | fi |
michael@0 | 920 | |
michael@0 | 921 | # Determine next log storage point |
michael@0 | 922 | slot=`ls -1 "$ARCHIVE" | grep $DATE | wc -l` |
michael@0 | 923 | slot=`expr $slot + 1` |
michael@0 | 924 | location="$ARCHIVE/$DATE.$slot" |
michael@0 | 925 | mkdir -p "$location" |
michael@0 | 926 | |
michael@0 | 927 | # Archive the logs |
michael@0 | 928 | mv nisccBuildLog "$location" 2> /dev/null |
michael@0 | 929 | mv nisccBuildLogHack "$location" 2> /dev/null |
michael@0 | 930 | mv nisccLogSummary "$location" |
michael@0 | 931 | mv nisccLog* "$location" |
michael@0 | 932 | mv niscc_smime/p7m-ed-m-results.txt "$location" |
michael@0 | 933 | mv niscc_smime/p7m-sd-dt-results.txt "$location" |
michael@0 | 934 | mv niscc_smime/p7m-sd-op-results.txt "$location" |
michael@0 | 935 | |
michael@0 | 936 | # Archive any core files produced |
michael@0 | 937 | for core in `cat "$TEST_OUTPUT/crashLog"`; do |
michael@0 | 938 | mv "$core" "$location" |
michael@0 | 939 | mv "$core.details" "$location" |
michael@0 | 940 | done |
michael@0 | 941 | mv crashLog "$location" |
michael@0 | 942 | else |
michael@0 | 943 | # Logs not stored => summaries, crashlog and corefiles not moved, other logs deleted |
michael@0 | 944 | mv nisccLog00 nisccLog01 nisccLog02 nisccLog03 nisccLog04 nisccLog05 nisccLog06 nisccLog07 nisccLog08 nisccLog09 nisccLog10 nisccLog11 nisccLog12 TRASH/ |
michael@0 | 945 | mv niscc_smime/p7m-ed-m-results.txt niscc_smime/p7m-sd-dt-results.txt niscc_smime/p7m-sd-op-results.txt TRASH/ |
michael@0 | 946 | fi |
michael@0 | 947 | mv envDB sigDB niscc_smime niscc_ssl TRASH/ |
michael@0 | 948 | mv CA.p12 Client.p12 client_crt.p12 server_crt.p12 TRASH/ |
michael@0 | 949 | mv p7m-ed-m-files.txt p7m-sd-dt-files.txt p7m-sd-op-files.txt password-is-testtest1.txt detached.txt TRASH/ |
michael@0 | 950 | mv crashme.c crashme TRASH/ |
michael@0 | 951 | } |
michael@0 | 952 | |
michael@0 | 953 | ################################################################################ |
michael@0 | 954 | # Main |
michael@0 | 955 | ################################################################################ |
michael@0 | 956 | process_args $* |
michael@0 | 957 | create_environment |
michael@0 | 958 | hg_pull |
michael@0 | 959 | build_NSS |
michael@0 | 960 | init |
michael@0 | 961 | niscc_smime |
michael@0 | 962 | niscc_ssl_init |
michael@0 | 963 | force_crash |
michael@0 | 964 | ssl_setup_dirs_simple |
michael@0 | 965 | ssl_simple_client_auth |
michael@0 | 966 | ssl_simple_server_auth |
michael@0 | 967 | ssl_simple_rootca |
michael@0 | 968 | ssl_setup_dirs_resigned |
michael@0 | 969 | ssl_resigned_client_auth |
michael@0 | 970 | ssl_resigned_server_auth |
michael@0 | 971 | ssl_resigned_rootca |
michael@0 | 972 | # no idea what these commented-out lines are supposed to be! |
michael@0 | 973 | #ssl_setup_dirs_update |
michael@0 | 974 | # ssl_update_server_auth der |
michael@0 | 975 | # ssl_update_client_auth der |
michael@0 | 976 | # ssl_update_server_auth resigned-der |
michael@0 | 977 | # ssl_update_client_auth resigned-der |
michael@0 | 978 | log_summary |
michael@0 | 979 | mail_testLog |
michael@0 | 980 | core_process |
michael@0 | 981 | move_files |
michael@0 | 982 | exit $SIZE |