Removed submodules

This commit is contained in:
2026-05-31 14:34:00 -04:00
commit 46c36b11da
352 changed files with 14792 additions and 0 deletions
+87
View File
@@ -0,0 +1,87 @@
#
# Simple Test Makefile
# Mike Lam, James Madison University, August 2016
#
# This version of the Makefile includes support for building a test suite. The
# recommended framework is Check (http://check.sourceforge.net/). To build and
# run the test suite, execute the "test" target. The test suite must be located
# in a module called "testsuite". The MODS, LIBS, and OBJS variables work as
# they do in the main Makefile.
#
# To change the default build target (which executes when you just type
# "make"), change the right-hand side of the definition of the "default"
# target.
#
# By default, this makefile will build the project with debugging symbols and
# without optimization. To change this, edit or remove the "-g" and "-O0"
# options in CFLAGS and LDFLAGS accordingly.
#
# By default, this makefile build the application using the GNU C compiler,
# adhering to the C99 standard with all warnings enabled.
# application-specific settings and run target
EXE=../digduke
TEST=testsuite
MODS=public.o
OBJS=../port_utils.o
LIBS=
UTESTOUT=utests.txt
ITESTOUT=itests.txt
SCHECKOUT=style.txt
default: $(TEST)
$(EXE):
make -C ../
test: itest style
@echo "========================================"
utest: $(EXE) $(TEST)
@echo "========================================"
@echo " UNIT TESTS"
@./$(TEST) 2>/dev/null >$(UTESTOUT)
@cat $(UTESTOUT) | sed -n -e '/Checks/,$$p' | sed -e 's/^private.*:[EF]://g'
itest: $(EXE)
@echo "========================================"
@echo " INTEGRATION TESTS"
@./integration.sh | tee $(ITESTOUT)
style: $(EXE)
@echo "========================================"
@echo " CODING STYLE CHECK"
@./style.sh 2>/dev/null >$(SCHECKOUT)
@cat $(SCHECKOUT)
# compiler/linker settings
CC=gcc
CFLAGS=-g -O0 -Wall --std=gnu99 -pedantic
LDFLAGS=-g -O0
CFLAGS=
LIBS+=-lcheck -lm -lpthread
ifeq ($(shell uname -s),Linux)
LIBS+=-lrt -lsubunit
endif
# build targets
$(TEST): $(TEST).o $(MODS) $(OBJS)
$(CC) $(LDFLAGS) -o $(TEST) $^ $(LIBS)
%.o: %.c
$(CC) -c $(CFLAGS) $<
clean:
rm -rf $(TEST) $(TEST).o $(MODS) $(UTESTOUT) $(ITESTOUT) $(SCHECKOUT) outputs valgrind ckstyle
.PHONY: default clean test unittest inttest
BIN
View File
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 32412
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;stu. IN A
;; ANSWER SECTION:
stu. IN CNAME 0. stu.cs.jmu.edu.
stu.cs.jmu.edu. IN A 0. 127.0.1.1
@@ -0,0 +1,11 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51120
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; QUESTION SECTION:
;www.jmu.edu. IN CNAME
;; ANSWER SECTION:
www.jmu.edu. IN CNAME 592. it-www1.jmu.edu.
;; ADDITIONAL SECTION:
it-www1.jmu.edu. IN A 900. 134.126.126.99
+8
View File
@@ -0,0 +1,8 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49602
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;stu.cs.jmu.edu. IN CNAME
;; ANSWER SECTION:
stu.cs.jmu.edu. IN CNAME 1769. student.cs.jmu.edu.
+8
View File
@@ -0,0 +1,8 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52173
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;example.com. IN SOA
;; ANSWER SECTION:
example.com. IN SOA 1803. ns.icann.org. noc.dns.icann.org. 2025011715 7200 3600 1209600 3600
+8
View File
@@ -0,0 +1,8 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62055
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;jmu.edu. IN SOA
;; ANSWER SECTION:
jmu.edu. IN SOA 3600. it-ns.jmu.edu. network.jmu.edu. 735142168 86400 7200 3600000 3600
@@ -0,0 +1,11 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 61906
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;www.jmu.edu. IN AAAA
;; ANSWER SECTION:
www.jmu.edu. IN CNAME 592. it-www1.jmu.edu.
;; AUTHORITY SECTION:
jmu.edu. IN SOA 3600. it-ns.jmu.edu. network.jmu.edu. 735142168 86400 7200 3600000 3600
@@ -0,0 +1,8 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10099
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;fac.cs.jmu.edu. IN AAAA
;; AUTHORITY SECTION:
cs.jmu.edu. IN SOA 900. it-nios-gm.jmu.edu. network.jmu.edu. 14 10800 3600 2419200 900
+8
View File
@@ -0,0 +1,8 @@
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 56769
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;5.67.101.151.in-addr.arpa. IN PTR
;; AUTHORITY SECTION:
151.in-addr.arpa. IN SOA 3600. pri.authdns.ripe.net. dns.ripe.net. 1752675523 3600 600 864000 3600
+8
View File
@@ -0,0 +1,8 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 870
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;221.141.126.134.in-addr.arpa. IN PTR
;; ANSWER SECTION:
221.141.126.134.in-addr.arpa. IN PTR 3542. student.cs.jmu.edu.
+12
View File
@@ -0,0 +1,12 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45675
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; QUESTION SECTION:
;1.1.0.127.in-addr.arpa. IN PTR
;; ANSWER SECTION:
1.1.0.127.in-addr.arpa. IN PTR 0. stu.cs.jmu.edu.
1.1.0.127.in-addr.arpa. IN PTR 0. stu.
;; ADDITIONAL SECTION:
1.1.0.127.in-addr.arpa. IN CNAME 1769. student.cs.jmu.edu.
+13
View File
@@ -0,0 +1,13 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57548
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;99.126.126.134.in-addr.arpa. IN PTR
;; ANSWER SECTION:
99.126.126.134.in-addr.arpa. IN PTR 1483. it-www1.jmu.edu.
99.126.126.134.in-addr.arpa. IN PTR 1483. spcecoms.jmu.edu.
99.126.126.134.in-addr.arpa. IN PTR 1483. groups.jmu.edu.
99.126.126.134.in-addr.arpa. IN PTR 1483. groups.dukes.jmu.edu.
99.126.126.134.in-addr.arpa. IN PTR 1483. it-www2.jmu.edu.
99.126.126.134.in-addr.arpa. IN PTR 1483. athletics.jmu.edu.
+13
View File
@@ -0,0 +1,13 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7059
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;example.com. IN A
;; ANSWER SECTION:
example.com. IN A 300. 96.7.128.198
example.com. IN A 300. 23.215.0.136
example.com. IN A 300. 23.192.228.80
example.com. IN A 300. 23.192.228.84
example.com. IN A 300. 96.7.128.175
example.com. IN A 300. 23.215.0.138
+13
View File
@@ -0,0 +1,13 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4801
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;example.com. IN AAAA
;; ANSWER SECTION:
example.com. IN AAAA 21. 2600:1406:3a00:21::173e:2e65
example.com. IN AAAA 21. 2600:1406:bc00:53::b81e:94c8
example.com. IN AAAA 21. 2600:1408:ec00:36::1736:7f24
example.com. IN AAAA 21. 2600:1406:3a00:21::173e:2e66
example.com. IN AAAA 21. 2600:1408:ec00:36::1736:7f31
example.com. IN AAAA 21. 2600:1406:bc00:53::b81e:94ce
@@ -0,0 +1,9 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 42937
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;example.com. IN NS
;; ANSWER SECTION:
example.com. IN NS 84682. b.iana-servers.net.
example.com. IN NS 84682. a.iana-servers.net.
+8
View File
@@ -0,0 +1,8 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57867
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;example.com. IN MX
;; ANSWER SECTION:
example.com. IN MX 86400. 0 .
+8
View File
@@ -0,0 +1,8 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13835
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;jmu.edu. IN MX
;; ANSWER SECTION:
jmu.edu. IN MX 1538. 0 jmu-edu.mail.protection.outlook.com.
+9
View File
@@ -0,0 +1,9 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23379
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;jmu.edu. IN NS
;; ANSWER SECTION:
jmu.edu. IN NS 1798. it-ns2-19.jmu.edu.
jmu.edu. IN NS 1798. it-ns1-19.jmu.edu.
+5
View File
@@ -0,0 +1,5 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54920
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;localhost. IN AAAA
+8
View File
@@ -0,0 +1,8 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;jmu.edu. IN A
;; ANSWER SECTION:
jmu.edu. IN A 900. 134.126.126.99
+8
View File
@@ -0,0 +1,8 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46412
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;google.com. IN A
;; ANSWER SECTION:
google.com. IN A 194. 142.250.31.113
+8
View File
@@ -0,0 +1,8 @@
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39713
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;localhost. IN A
;; ANSWER SECTION:
localhost. IN A 0. 127.0.0.1
+5
View File
@@ -0,0 +1,5 @@
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 22016
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;asdf. IN A
+14
View File
@@ -0,0 +1,14 @@
Sending 17 bytes to 127.0.0.1:
0001 0100 0001 0000 0000 0000 0000 0100
01
Received 51 bytes from 127.0.0.1:
0001 8180 0001 0001 0000 0000 0000 0100
0101 620c 726f 6f74 2d73 6572 7665 7273
036e 6574 0000 0100 0100 008c a000 04aa
f7aa 02
Domain name: b.root-servers.net.
Record type: IN A
TTL: 36000
IPv4 address: 170.247.170.2
+14
View File
@@ -0,0 +1,14 @@
Sending 17 bytes to 127.0.0.1:
0001 0100 0001 0000 0000 0000 0000 0100
01
Received 51 bytes from 127.0.0.1:
0001 8180 0001 0001 0000 0000 0000 0100
0101 610c 726f 6f74 2d73 6572 7665 7273
036e 6574 0000 0100 0100 0000 0a00 04c6
2900 04
Domain name: a.root-servers.net.
Record type: IN A
TTL: 10
IPv4 address: 198.41.0.4
+97
View File
@@ -0,0 +1,97 @@
#!/bin/bash
EXE="../digduke"
function run_test {
# parameters
TAG=$1
shift
ARGS=$1
shift
PTAG=$(printf '%-30s' "$TAG")
if [[ $(echo $TAG | cut -d'_' -f1) == $SKIP_C ||
$(echo $TAG | cut -d'_' -f1) == $SKIP_B ||
$(echo $TAG | cut -d'_' -f1) == $SKIP_A ]] ; then
echo "$PTAG SKIPPED (previous phases not complete)"
return
fi
# file paths
OUTPUT=outputs/$TAG.txt
DIFF=outputs/$TAG.diff
EXPECT=expected/$TAG.txt
VALGRND=valgrind/$TAG.txt
# run test and compare output to the expected version
./dukens -s 2 >/dev/null 2>&1 &
sleep 1
$EXE $ARGS 2>/dev/null >"$OUTPUT"
for ARG in "$@" ; do
$EXE $ARG 2>/dev/null >>"$OUTPUT"
done
diff -u "$OUTPUT" "$EXPECT" >"$DIFF"
passed=false
EFILES=$(find expected -type f -name "$TAG-*.txt")
if [ ! -s "$DIFF" ]; then
passed=true
elif [ "$EFILES" != "" ]; then
for EF in $EFILES ; do
DF=$(echo $EF | sed 's/^expected/outputs/' | sed 's/txt$/diff/')
diff -u "$OUTPUT" "$EF" >"$DF"
if [ ! -s "$DF" ]; then
passed=true
fi
done
fi
if [[ $passed = true ]] ; then
echo "$PTAG pass"
rm outputs/$TAG*diff
else
echo "$PTAG FAIL - Command line: $EXE $ARGS"
if [ "$EFILES" != "" ] ; then
echo "$(printf '%30s' ' ') *WARNING* This test has more than one possible output file."
echo "$(printf '%30s' ' ') *WARNING* Please inspect each manually for comparison."
else
echo "$(printf '%30s' ' ') See $DIFF for diff with expected output"
fi
echo ""
if [[ $(echo $PTAG | cut -d'_' -f1) == 'D' ]] ; then
SKIP_C="C"
SKIP_B="B"
SKIP_A="A"
elif [[ $(echo $PTAG | cut -d'_' -f1) == 'C' ]] ; then
SKIP_B="B"
SKIP_A="A"
elif [[ $(echo $PTAG | cut -d'_' -f1) == 'B' ]] ; then
SKIP_A="A"
fi
fi
# run valgrind
#./dukens -s 2 >/dev/null 2>&1 &
# sleep 1
# valgrind $EXE $ARGS >"$VALGRND" 2>&1
}
# initialize output folders
mkdir -p outputs
mkdir -p valgrind
rm -f outputs/* valgrind/*
# run individual tests
source itests.include
# check for memory leaks
#LEAK=`cat valgrind/*.txt | grep 'definitely lost' | grep -v ' 0 bytes in 0 blocks'`
LEAK=
if [ -z "$LEAK" ]; then
echo "No memory leak found."
else
echo "Memory leak(s) found. See files listed below for details."
grep 'definitely lost' valgrind/*.txt | sed -e 's/:.*$//g' | sed -e 's/^/ - /g'
fi
+32
View File
@@ -0,0 +1,32 @@
# list of integration tests
# format: run_test <TAG> <ARGS>
# <TAG> used as the root for all filenames (i.e., "expected/$TAG.txt")
# <ARGS> command-line arguments to test
# sends a message to the server and prints the response in a formatted way
run_test D_ping ""
run_test C_a_basic "-x 2 jmu.edu A"
run_test C_a_compressed "-x 46412 google.com A"
run_test C_a_localhost "-x 39713 localhost A"
run_test C_bad_domain "-x 22016 asdf A"
run_test B_a_multiple "-x 7059 example.com A"
run_test B_aaaa "-x 4801 example.com AAAA"
run_test B_jmu_ns "-x 23379 jmu.edu NS"
run_test B_jmu_mx "-x 13835 jmu.edu MX"
run_test B_double_compress "-x 42937 example.com NS"
run_test B_empty_domain "-x 57867 example.com MX"
run_test B_no_ipv6 "-x 54920 localhost AAAA"
run_test A_cname_basic "-x 49602 stu.cs.jmu.edu CNAME"
run_test A_cname_additional "-x 51120 www.jmu.edu CNAME"
run_test A_cname_a "-x 32412 stu A"
run_test A_jmu_soa "-x 62055 jmu.edu SOA"
run_test A_example_soa "-x 52173 example.com SOA"
run_test A_ptr_basic "-x 870 134.126.141.221 PTR"
run_test A_ptr_multiple "-x 57548 134.126.126.99 PTR"
run_test A_ptr_mixed "-x 45675 127.0.1.1 PTR"
run_test A_no_ptr "-x 56769 151.101.67.5 PTR"
run_test A_no_ipv6_authority "-x 61906 www.jmu.edu AAAA"
run_test A_no_ipv6_subauth "-x 10099 fac.cs.jmu.edu AAAA"
Binary file not shown.
+53
View File
@@ -0,0 +1,53 @@
#!/bin/bash
STYLE="gnu"
IGNORE=()
FAIL=0
function comp_file {
SRC=$1
SRC_NAME=$2
# file paths
FORMAT=ckstyle/${SRC_NAME}.$STYLE
DIFF=ckstyle/${SRC_NAME}.diff
# run clang-format and compare results
clang-format --style=$STYLE $source > $FORMAT
diff -u $SRC $FORMAT >$DIFF
PTAG=$(printf '%-30s' "$SRC_NAME")
if [ -s $DIFF ]; then
echo "$PTAG FAIL (see $DIFF for details)"
FAIL=1
else
echo "$PTAG pass"
rm $DIFF
fi
rm $FORMAT
}
mkdir -p ckstyle
rm -f ckstyle/*
for source in $(ls ../src/*.c ../src/*.h) ; do
SKIP=0
src=$(basename $source)
for ignore in ${IGNORE[*]} ; do
if [ "$src" = "$ignore" ] ; then
SKIP=1
fi
done
if [ $SKIP = 0 ] ; then
comp_file $source $src
fi
done
if [ $FAIL != 0 ] ; then
echo "Code that does not adhere to GNU standards will not be accepted."
echo "You must fix these files before submission."
else
echo "Code correctly adheres to required style."
fi
View File