Skip to content

Commit ca343ae

Browse files
committed
Fix small issues in tests and added some extra checks.
1 parent 576aeda commit ca343ae

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

test/Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
CC = clang++
33
#CC = g++
44

5-
CFLAGS = -O0 -std=c++11 -DGTEST_USE_OWN_TR1_TUPLE -I.. -I. -Wall -Wextra
5+
CFLAGS = -ggdb -O0 -std=c++11 -DGTEST_USE_OWN_TR1_TUPLE -I.. -I. -Wall -Wextra
66
OPENSSL_SUPPORT = -DCPPHTTPLIB_OPENSSL_SUPPORT -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib -lssl -lcrypto
77
ZLIB_SUPPORT = -DCPPHTTPLIB_ZLIB_SUPPORT -lz
88

99
all : test
1010
./test
1111

12-
test : test.cc ../httplib.h Makefile
12+
test : test.cc ../httplib.h Makefile cert.pem
1313
$(CC) -o test $(CFLAGS) test.cc gtest/gtest-all.cc gtest/gtest_main.cc $(OPENSSL_SUPPORT) $(ZLIB_SUPPORT) -lpthread
1414

15-
pem:
15+
cert.pem:
1616
openssl genrsa 2048 > key.pem
17-
openssl req -new -key key.pem | openssl x509 -days 3650 -req -signkey key.pem > cert.pem
17+
openssl req -new -batch -config test.conf -key key.pem | openssl x509 -days 3650 -req -signkey key.pem > cert.pem
1818

1919
clean:
20-
rm test *.pem
20+
rm -f test *.pem

test/test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ class ServerTest : public ::testing::Test {
363363
persons_["john"] = "programmer";
364364

365365
t_ = thread([&](){
366-
svr_.listen(HOST, PORT);
366+
ASSERT_TRUE(svr_.listen(HOST, PORT));
367367
});
368368

369369
while (!svr_.is_running()) {
@@ -890,7 +890,7 @@ class ServerTestWithAI_PASSIVE : public ::testing::Test {
890890
});
891891

892892
t_ = thread([&]() {
893-
svr_.listen(nullptr, PORT, AI_PASSIVE);
893+
ASSERT_TRUE(svr_.listen(nullptr, PORT, AI_PASSIVE));
894894
});
895895

896896
while (!svr_.is_running()) {
@@ -932,7 +932,7 @@ class ServerUpDownTest : public ::testing::Test {
932932
t_ = thread([&](){
933933
svr_.bind_to_any_port(HOST);
934934
msleep(500);
935-
svr_.listen_after_bind();
935+
ASSERT_TRUE(svr_.listen_after_bind());
936936
});
937937

938938
while (!svr_.is_running()) {

test/test.conf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[req]
2+
default_bits = 2048
3+
distinguished_name = req_distinguished_name
4+
attributes = req_attributes
5+
prompt = no
6+
output_password = mypass
7+
8+
[req_distinguished_name]
9+
C = US
10+
ST = Test State or Province
11+
L = Test Locality
12+
O = Organization Name
13+
OU = Organizational Unit Name
14+
CN = Common Name
15+
emailAddress = [email protected]
16+
17+
[req_attributes]
18+
challengePassword = 1234

0 commit comments

Comments
 (0)