diff --git a/.gitignore b/.gitignore index af9c06c4..33342504 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ linux/ *.rpm test/tls-perf *pyc +test/*.bats diff --git a/Makefile b/Makefile index 016df2d8..303c5572 100644 --- a/Makefile +++ b/Makefile @@ -243,4 +243,6 @@ minigun: for i in `seq 1 100`; do curl \-4 -s localhost:8000/tls.c > /dev/null; echo $$?; done tests: + KTLS_IN_USE=true envsubst '$$KTLS_IN_USE' < test/tests.bats.template > test/ktls.bats + KTLS_IN_USE=false envsubst '$$KTLS_IN_USE' < test/tests.bats.template > test/non-ktls.bats ./test/bats/bin/bats test/ diff --git a/test/non-ktls.bats b/test/non-ktls.bats deleted file mode 100644 index 1898f6bf..00000000 --- a/test/non-ktls.bats +++ /dev/null @@ -1,68 +0,0 @@ -ktls_in_use=false; - -load 'test_helper/bats-support/load.bash' -load 'test_helper/bats-assert/load.bash' -load 'test_helper/common.bash' - -@test "Test if the non-ktls enabled kernel modul is in use" { - run cat /sys/module/camblet/parameters/ktls_available - assert_output 'N' -} - -@test "Test a normal directory listing with wget" { - wget -d http://localhost:8000/ -O /dev/null -} - -@test "Test downloading and uploading 2MB file with curl" { - head -c 2M bigfile.o - curl -v -o /tmp/bigfile_downloaded.o http://localhost:8000/bigfile.o - curl -v -F "bigfile_downloaded.o=@/tmp/bigfile_downloaded.o" http://localhost:8000/upload - diff bigfile.o bigfile_downloaded.o -} - -@test "Test bearSSL with non-bearSSL compatibility" { - echo "testing with curl using default cipher..." - curl -k -v https://localhost:7000/ - echo "testing with curl using AES_GCM_128 cipher..." - curl -k -v --ciphers ECDHE-RSA-AES128-GCM-SHA256 https://localhost:7000/ - echo "testing with curl using AES_GCM_256 cipher..." - curl -k -v --ciphers ECDHE-RSA-AES256-GCM-SHA384 https://localhost:7000/ - echo "testing with curl using CHACHA_POLY cipher..." - curl -k -v --ciphers ECDHE-RSA-CHACHA20-POLY1305 https://localhost:7000/ - echo "testing with wget..." - wget --no-check-certificate https://localhost:7000/ -O/dev/null -} - -@test "Test openssl client connect to python with various ciphers" { - echo -e "GET / HTTP/1.1\r\n\r\n" | openssl s_client -connect 127.0.0.1:7000 - echo "Test openssl client connect to python with ECDHE-RSA-CHACHA20-POLY1305 cipher" - echo -e "GET / HTTP/1.1\r\n\r\n" | openssl s_client -cipher ECDHE-RSA-CHACHA20-POLY1305 -connect 127.0.0.1:7000 -} - -@test "Test file-server under load using curl" { - echo "response" > testfile - echo -e " 100 0\n 100 response" > test.output - for i in `seq 1 100`; do curl -s localhost:8000/testfile; echo $?; done |sort|uniq -c|diff - test.output -} - -@test "Test sendfile with NGiNX under load using curl" { - echo -e " 100 0" > test.output - for i in `seq 1 100`; do curl -s -o/dev/null localhost:8080; echo $?; done |sort|uniq -c|diff - test.output -} - -@test "Test sendfile with NGiNX under load using wget" { - echo -e " 100 0" > test.output - for i in `seq 1 100`; do wget -q -O/dev/null localhost:8080; echo $?; done |sort|uniq -c|diff - test.output -} - -@test "Test sockopt on file-server with TLS" { - ./sockopt -} - -@test "Test passthrough ALPN on file-server with TLS" { - python3 test/passthrough.py -} - -@test "Test various recv flag parameters" { - ./flags -} \ No newline at end of file diff --git a/test/setup_suite.bash b/test/setup_suite.bash index a673a3be..c76f3b90 100644 --- a/test/setup_suite.bash +++ b/test/setup_suite.bash @@ -1,5 +1,7 @@ #!/usr/bin/env bash +TEST_TAG=0.0.0 + # Runs only once in the beginning of the suite setup_suite() { _install_setup_prerequisits @@ -19,7 +21,6 @@ _install_setup_prerequisits() { } _build_and_install_camblet_with_dkms() { - TEST_TAG=0.0.0 sudo cp -r . /usr/src/camblet-$TEST_TAG/ sudo dkms add -m camblet -v $TEST_TAG if sudo dkms build -m camblet -v $TEST_TAG; then @@ -65,7 +66,7 @@ teardown_suite() { _teardown_file_server_build _teardown_flags _teardown_sockopt - sudo dkms remove camblet/$TEST_TAG + sudo dkms remove camblet/$TEST_TAG --all sudo rm -rf /usr/src/camblet-$TEST_TAG/ } diff --git a/test/test_helper/common.bash b/test/test_helper/common.bash index a96e1296..f9df716f 100644 --- a/test/test_helper/common.bash +++ b/test/test_helper/common.bash @@ -23,7 +23,7 @@ setup_file() { _run_kernel_modul() { - if $ktls_in_use; then + if [[ $ktls_in_use = "true" ]]; then echo '# Running tests with ktls' >&3 sudo modprobe tls sudo modprobe camblet dyndbg==_ ktls_available=1 diff --git a/test/ktls.bats b/test/tests.bats.template similarity index 93% rename from test/ktls.bats rename to test/tests.bats.template index c8a394c3..276b6fe7 100644 --- a/test/ktls.bats +++ b/test/tests.bats.template @@ -1,12 +1,12 @@ -ktls_in_use=true; +ktls_in_use=${KTLS_IN_USE} load 'test_helper/bats-support/load.bash' load 'test_helper/bats-assert/load.bash' load 'test_helper/common.bash' -@test "Test if the ktls enabled kernel modul is in use" { +@test "Test if the ktls enabled kernel module is in use" { run cat /sys/module/camblet/parameters/ktls_available - assert_output 'Y' + assert_output $([ $ktls_in_use = "true" ] && echo 'Y' || echo 'N') } @test "Test a normal directory listing with wget" { @@ -65,4 +65,4 @@ load 'test_helper/common.bash' @test "Test various recv flag parameters" { ./flags -} \ No newline at end of file +}