Skip to content
Closed
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
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ env:
- COMP=nss OS_TYPE=centos OS_VERSION=5
- COMP=nss OS_TYPE=centos OS_VERSION=6
- COMP=nss OS_TYPE=centos OS_VERSION=7
- COMP=nss OS_TYPE=fedora OS_VERSION=24
- COMP=nss OS_TYPE=fedora OS_VERSION=24 TEST_GLOB='@(renego*)'
- COMP=nss OS_TYPE=fedora OS_VERSION=24 TEST_GLOB='!(renego*)'
# gnutls tests
- COMP=gnutls OS_TYPE=centos OS_VERSION=5
- COMP=gnutls OS_TYPE=centos OS_VERSION=6
Expand All @@ -25,4 +26,4 @@ before_install:
- sudo docker pull ${OS_TYPE}:${OS_VERSION}

script:
- ./scripts/test-setup.sh ${OS_TYPE} ${OS_VERSION} ${COMP}
- ./scripts/test-setup.sh ${OS_TYPE} ${OS_VERSION} ${COMP} "${TEST_GLOB}"
15 changes: 12 additions & 3 deletions gnutls/Interoperability/TLSv1-2-with-NSS/nss-client.expect
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ spawn /bin/sh -c "$argv"
expect {
"Enter Password" { send "RedHatEnterpriseLinux6.6\r"; exp_continue }
eof { }
"subject DN" { send "GET / HTTP/1.0\r\r";
expect -timeout 5 "HTTP/1.0 200 OK" { close; exit 0}
close; exit 1}
"subject DN" {
send "GET / HTTP/1.0\r\r";
expect -timeout 5 "HTTP/1.0 200 OK" {
expect -re ".+" {
close;
exit 0;
}
}

close;
exit 1;
}
}
set info [wait]
#puts "Return from wait: $info"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ expect {
send "client hello\r"
expect {
"server hello" {
sleep 1
close
exit 0
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ expect {
send "client hello\r"
expect "client hello" {
expect "client hello" {
close
exit 0
expect -re ".+" {
close
exit 0
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions gnutls/Interoperability/renegotiation-with-NSS/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,4 @@ rlJournalStart
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ rlJournalStart
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState
1 change: 1 addition & 0 deletions gnutls/Interoperability/resumption-with-NSS/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,4 @@ rlJournalStart
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState
1 change: 1 addition & 0 deletions gnutls/Interoperability/resumption-with-OpenSSL/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,4 @@ rlJournalStart
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState
2 changes: 1 addition & 1 deletion gnutls/Interoperability/softhsm-integration/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ $(METADATA): Makefile
@echo "License: GPLv2+" >> $(METADATA)
@echo "Confidential: yes" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
@echo "Releases: -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA)
@echo "Releases: -RHEL4 -RHELClient5 -RHELServer5 -RHEL6 -RHEL7" >> $(METADATA)

1 change: 1 addition & 0 deletions gnutls/Interoperability/softhsm-integration/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ _EOF
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState
5 changes: 3 additions & 2 deletions nss/Interoperability/CC-nss-with-gnutls/gnutls-client.expect
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ expect {
send "GET / HTTP/1.0\r\r";
expect {
"Generic Web Server" {
close
exit 0
sleep 1
close
exit 0
}
}
}
Expand Down
15 changes: 12 additions & 3 deletions nss/Interoperability/CC-nss-with-gnutls/nss-client.expect
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ spawn /bin/sh -c "$argv"
expect {
"Enter Password" { send "RedHatEnterpriseLinux6.6\r"; exp_continue }
eof { }
"subject DN" { send "GET / HTTP/1.0\r\r";
expect -timeout 5 "HTTP/1.0 200 OK" { close; exit 0}
close; exit 1}
"subject DN" {
send "GET / HTTP/1.0\r\r";
expect -timeout 5 "HTTP/1.0 200 OK" {
expect -re ".+" {
close;
exit 0;
}
}

close;
exit 1;
}
}
set info [wait]
#puts "Return from wait: $info"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ expect {
"Verify return code: 0 " {
send "GET / HTTP/1.0\r\r"
expect "Server: Generic Web Server" {
close
exit 0
expect -re ".+" {
close
exit 0
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ spawn /bin/sh -c "$argv"
expect {
"Enter Password" { send "RedHatEnterpriseLinux6.6\r"; exp_continue }
eof { }
"subject DN" { expect "subject DN" { send "GET / HTTP/1.0\r\r";
expect -timeout 5 "Verify return code";
close}}
"subject DN" {
expect "subject DN" {
send "GET / HTTP/1.0\r\r";
expect -timeout 5 "Verify return code";
sleep 1;
close;
}
}
}
set info [wait]
#puts "Return from wait: $info"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,3 +599,4 @@ rlJournalStart
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState
35 changes: 35 additions & 0 deletions scripts/test-runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ function keep_alive() {
done
}

# Compare test name with glob expression using extended glob patterns
# $1 - test name
# $2 - glob pattern
function test_name_relevancy() {
# See: http://wiki.bash-hackers.org/syntax/pattern#extended_pattern_language
# Save the original state
shopt -q extglob
local STATE=$?
# Enable extglob
shopt -s extglob
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we want to preserve the environment, it should first query the state of the setting and then set it, and then restore it, otherwise it will disable it if it is run on a system with it enabled

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That definitely makes sense, thanks.

[[ $1 == $2 ]]
local RES=$?
# If the extension was originally disabled, disable it
if [[ $STATE -ne 0 ]]; then
shopt -u extglob
fi

return $RES
}

set +x

if [[ $# < 3 ]]; then
Expand All @@ -31,6 +51,7 @@ fi
OS_TYPE="$1"
OS_VERSION="$2"
COMPONENT="$3"
TEST_GLOB="$4"
if [[ $OS_TYPE == "fedora" ]]; then
PKG_MAN="dnf"
else
Expand Down Expand Up @@ -72,12 +93,26 @@ do
SKIP=0

echo "Running test: $test"

# Check if glob pattern is set
if [[ ! -z "$TEST_GLOB" ]]; then
# If so, check if it matches current test name
TEST_NAME="$(basename $(dirname "$test"))"
if ! test_name_relevancy "$TEST_NAME" "$TEST_GLOB"; then
echo "Test '$TEST_NAME' excluded by given glob expression: $TEST_GLOB"
SKIPPED+=("$test")
continue
fi
fi

# Makefile is necessary for test execution
pushd "$(dirname "$test")"
if [[ ! -f Makefile ]]; then
echo >&2 "Missing Makefile"
EC=1
SKIP=1
fi

if [[ $SKIP -eq 0 ]]; then
# Check relevancy
if relevancy.awk -v os_type=$OS_TYPE -v os_ver=$OS_VERSION Makefile; then
Expand Down
20 changes: 19 additions & 1 deletion scripts/test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,28 @@ fi
OS_TYPE="$1"
OS_VERSION="$2"
COMPONENT="$3"
TEST_GLOB="$4"
CONT_NAME="${OS_TYPE}-${OS_VERSION}-${COMPONENT}"
CERTGEN_REPO="https://github.com/redhat-qe-security/certgen"
CERTGEN_PATH="openssl/Library/certgen"

# Test sanity check
# Check if all tests have rlGetTestState at their end
FAILED_CHECKS=0
FAILED_NAMES=()
while read file; do
if ! grep -Pzoq "rlGetTestState[[:space:]]*$" "$file"; then
FAILED_CHECKS=$(($FAILED_CHECKS+1))
FAILED_NAMES+=("$file")
fi
done <<< "$(find . -type f -name "runtest.sh")"

if [[ $FAILED_CHECKS -gt 0 ]]; then
echo "Following tests are missing rlGetTestState command:"
printf '%s\n' "${FAILED_NAMES[@]}"
exit 1
fi

# Prepare necessary libraries
# openssl/certgen:
TMP_DIR="$(mktemp -d tmp.XXXXX)"
Expand All @@ -33,4 +51,4 @@ sudo docker run --rm --name "$CONT_NAME" \
-v $PWD:/workspace:rw \
${OS_TYPE}:${OS_VERSION} \
/bin/bash -c \
"bash -x $RUNNER $OS_TYPE $OS_VERSION $COMPONENT"
"bash -x $RUNNER $OS_TYPE $OS_VERSION $COMPONENT '$TEST_GLOB'"