Skip to content

Commit

Permalink
add some tests for the different log styles
Browse files Browse the repository at this point in the history
  • Loading branch information
omar-polo committed Aug 29, 2024
1 parent 11b14c9 commit e132ebe
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions regress/regress
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ run_test test_proxy_with_certs
# run_test test_unknown_host # XXX: breaks on some distro
run_test test_include_mime
run_test test_log_file
run_test test_log_common
run_test test_log_combined
run_test test_ipv4_addr
run_test test_ipv6_addr need_ipv6
run_test test_ipv6_server need_ipv6
Expand Down
46 changes: 46 additions & 0 deletions regress/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit e132ebe

Please sign in to comment.