diff options
author | Omar Polo <op@omarpolo.com> | 2024-08-29 17:37:56 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2024-08-29 17:37:56 +0000 |
commit | e132ebe389243bd22fc07a1191cb7ceabc6287eb (patch) | |
tree | d093582214f2b3b58586ca47cfe91f27c305aeef /regress/tests.sh | |
parent | 11b14c9228d5343f6d37ce485a38d22dadca4ec4 (diff) |
add some tests for the different log styles
Diffstat (limited to 'regress/tests.sh')
-rw-r--r-- | regress/tests.sh | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/regress/tests.sh b/regress/tests.sh index b2fe511..f4dc0eb 100644 --- a/regress/tests.sh +++ b/regress/tests.sh @@ -517,6 +517,52 @@ log style legacy' return 0 } +test_log_common() { + rm -f log log.edited + setup_simple_test ' +log access "'$PWD'/log" +log style common' + + fetch_hdr / + check_reply '20 text/gemini' + + # remove the ip and timestamp + awk '{$2 = ""; $5 = "timestamp"; print $0}' log > log.edited + + printf '%s\n' 'localhost - - timestamp +0200 "gemini://localhost/" 20 0' \ + | cmp -s - log.edited + if [ $? -ne 0 ]; then + # keep the log for post-mortem analysis + return 1 + fi + + rm -f log log.edited + return 0 +} + +test_log_combined() { + rm -f log log.edited + setup_simple_test ' +log access "'$PWD'/log" +log style combined' + + fetch_hdr / + check_reply '20 text/gemini' + + # remove the ip and timestamp + awk '{$1 = ""; print gensub("\\[.*\\]", "[timestamp]", 1)}' log > log.edited + + printf '%s\n' ' - - [timestamp] "gemini://localhost/" 20 0 "-" ""' \ + | cmp -s - log.edited + if [ $? -ne 0 ]; then + # keep the log for post-mortem analysis + return 1 + fi + + rm -f log log.edited + return 0 +} + test_ipv4_addr() { server_name="*" host="127.0.0.1" |