forked from nikhilm/qhttpserver
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add two dummy unit tests, to validate the minimal requirements : lib …
…linking and server start
- Loading branch information
Showing
15 changed files
with
222 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
SET(QHTTPSERVER_INCLUDE_DIR @CMAKE_INSTALL_PREFIX@/include) | ||
SET(QHTTPSERVER_LIBRARY_DIRS @CMAKE_INSTALL_PREFIX@/${LIB_INSTALL_DIR}) | ||
|
||
set(QHTTPSERVER_VERSION_MAJOR "0") | ||
set(QHTTPSERVER_VERSION_MINOR "2") | ||
set(QHTTPSERVER_VERSION_RELEASE "@VERSION_RELEASE@") | ||
|
||
set(QHTTPSERVER_VERSION "${QHTTPSERVER_VERSION_MAJOR}.${QHTTPSERVER_VERSION_MINOR}.${QHTTPSERVER_VERSION_RELEASE}") | ||
|
||
set(QHTTPSERVER_GENERIC_LIB_VERSION ${QHTTPSERVER_VERSION}) | ||
set(QHTTPSERVER_GENERIC_LIB_SOVERSION ${QHTTPSERVER_VERSION_MINOR}) | ||
|
||
|
||
message(STATUS "QHttpServer version ${QHTTPSERVER_VERSION} - QHTTPSERVER_GENERIC_LIB_VERSION ${QHTTPSERVER_GENERIC_LIB_VERSION} ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
add_subdirectory(helloworld) | ||
add_subdirectory(greeting) | ||
#add_subdirectory(bodydata) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src) | ||
|
||
add_definitions( -DQHTTPSERVER_EXPORT ) | ||
|
||
SET(œ_EXE_SRCS | ||
bodydata.cpp | ||
) | ||
|
||
add_executable(bodydata_server ${bodydata_EXE_SRCS}) | ||
|
||
target_link_libraries(bodydata_server qhttpserver ${Qt5_LIBRARIES}) | ||
|
||
add_test( | ||
NAME bodydata_Test | ||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test/bodydata.sh ${CMAKE_CURRENT_BINARY_DIR} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
#------------------------------------------------------------------------------- | ||
# to ensure the script actually runs inside its own folder | ||
MY_PATH="`dirname \"$0\"`" # relative | ||
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized | ||
if [ -z "$MY_PATH" ] ; then | ||
# Error. for some reason, the path is not accessible | ||
# to the script (e.g. permissions re-evaled after suid) | ||
exit 1 # Fail | ||
fi | ||
|
||
BINARY_DIR=$1 | ||
|
||
coproc $BINARY_DIR/bodydata_server | ||
SERVER_PID=$! | ||
|
||
expected="$MY_PATH/expected.html" | ||
observed="output.html" | ||
\rm -f $observed | ||
|
||
curl --request GET \ | ||
--url http://localhost:8080/user/abc \ | ||
-o $observed | ||
if cmp -s "$expected" "$observed"; then | ||
echo "All good" | ||
else | ||
echo "Unexpected response from server" | ||
exit 1 | ||
fi | ||
\rm -f $observed | ||
|
||
kill $SERVER_PID | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<html><head><title>BodyData App</title></head><body><h1>Hello abc!</h1><p></p></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src) | ||
|
||
add_definitions( -DQHTTPSERVER_EXPORT ) | ||
|
||
SET(greeting_EXE_SRCS | ||
greeting.cpp | ||
) | ||
|
||
add_executable(greeting_server ${greeting_EXE_SRCS}) | ||
|
||
target_link_libraries(greeting_server qhttpserver ${Qt5_LIBRARIES}) | ||
|
||
add_test( | ||
NAME greeting_Test | ||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test/greeting.sh ${CMAKE_CURRENT_BINARY_DIR} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
You aren't allowed here! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<html><head><title>Greeting App</title></head><body><h1>Hello abc!</h1></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
#------------------------------------------------------------------------------- | ||
# to ensure the script actually runs inside its own folder | ||
MY_PATH="`dirname \"$0\"`" # relative | ||
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized | ||
if [ -z "$MY_PATH" ] ; then | ||
# Error. for some reason, the path is not accessible | ||
# to the script (e.g. permissions re-evaled after suid) | ||
exit 1 # Fail | ||
fi | ||
|
||
BINARY_DIR=$1 | ||
coproc $BINARY_DIR/greeting_server | ||
SERVER_PID=$! | ||
|
||
expected="$MY_PATH/bad_user_expected.txt" | ||
observed="output.txt" | ||
\rm -f $observed | ||
|
||
curl --request GET \ | ||
--url http://localhost:8080 \ | ||
-o $observed | ||
if cmp -s "$expected" "$observed"; then | ||
echo "All good" | ||
else | ||
echo "Unexpected response from server" | ||
exit 1 | ||
fi | ||
\rm -f $observed | ||
|
||
|
||
expected="$MY_PATH/expected.html" | ||
curl --request GET \ | ||
--url http://localhost:8080/user/abc \ | ||
-o $observed | ||
if cmp -s "$expected" "$observed"; then | ||
echo "All good" | ||
else | ||
echo "Unexpected response from server" | ||
exit 1 | ||
fi | ||
\rm -f $observed | ||
|
||
kill $SERVER_PID | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src) | ||
|
||
add_definitions( -DQHTTPSERVER_EXPORT ) | ||
|
||
SET(helloworld_EXE_SRCS | ||
helloworld.cpp | ||
) | ||
|
||
add_executable(helloworld_server ${helloworld_EXE_SRCS}) | ||
|
||
target_link_libraries(helloworld_server qhttpserver ${Qt5_LIBRARIES}) | ||
|
||
add_test( | ||
NAME helloworld_Test | ||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test/helloworld.sh ${CMAKE_CURRENT_BINARY_DIR} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello World |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
#------------------------------------------------------------------------------- | ||
# to ensure the script actually runs inside its own folder | ||
MY_PATH="`dirname \"$0\"`" # relative | ||
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized | ||
if [ -z "$MY_PATH" ] ; then | ||
# Error. for some reason, the path is not accessible | ||
# to the script (e.g. permissions re-evaled after suid) | ||
exit 1 # Fail | ||
fi | ||
|
||
BINARY_DIR=$1 | ||
coproc $BINARY_DIR/helloworld_server | ||
SERVER_PID=$! | ||
|
||
expected="$MY_PATH/expected.txt" | ||
observed="output.txt" | ||
\rm -f $observed | ||
|
||
curl --request GET \ | ||
--url http://localhost:8080 \ | ||
-o $observed | ||
if cmp -s "$expected" "$observed"; then | ||
echo "All good" | ||
else | ||
echo "Unexpected response from server" | ||
exit 1 | ||
fi | ||
\rm -f $observed | ||
|
||
kill $SERVER_PID | ||
|
||
exit 0 |