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
+89
View File
@@ -0,0 +1,89 @@
#
# 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=../dukesh
TEST=testsuite
MODS=public.o
OBJS=../build/process.o ../build/shell.o ../build/builtins.o ../build/cmd.o ../build/hash.o
LIBS=
UTESTOUT=utests.txt
ITESTOUT=itests.txt
SCHECKOUT=style.txt
default: $(TEST)
$(EXE):
make -C ../
test: utest 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=c99 -pedantic -D_POSIX_C_SOURCE=200809L
LDFLAGS=-g -O0
#CFLAGS+=-I/opt/local/include -Wno-gnu-zero-variadic-macro-arguments
CFLAGS+=-Wno-gnu-zero-variadic-macro-arguments
#LDFLAGS+=-L/opt/local/lib
LDFLAGS=
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.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+2
View File
@@ -0,0 +1,2 @@
hello,world,me
later,gator
1 hello,world,me
2 later,gator
+2
View File
@@ -0,0 +1,2 @@
hello world me
later gator
+1
View File
@@ -0,0 +1 @@
oops
+1
View File
@@ -0,0 +1 @@
First
View File
+2
View File
@@ -0,0 +1,2 @@
pwd
quit
+1
View File
@@ -0,0 +1 @@
yet another test file
+10
View File
@@ -0,0 +1,10 @@
$ ./bin/cat cut_data/data.csv
hello,world,me
later,gator
$ ./bin/cat cut_data/data.csv | ./bin/cut -d , -f 2
world
gator
$ ./bin/cat cut_data/data.csv | tail -n 1
later,gator
$ quit
+17
View File
@@ -0,0 +1,17 @@
$ export A=5
$ ./bin/env ./bin/repeat 1 A
A=5
$ ./bin/env B=6 C=7 ./bin/repeat 1 A 2 B 3 C
A=5
B=6
B=6
C=7
C=7
C=7
$ ./bin/env C=7 ./bin/repeat 1 A 2 B 3 C | head -n 4
A=5
B=
B=
C=7
$ quit
+17
View File
@@ -0,0 +1,17 @@
$ ./bin/ls -a data | ./bin/head -n 1
empty.txt
$ ./bin/ls -a data | ./bin/head -n 2000
empty.txt
FIRST.txt
.hidden.txt
pwd.txt
subdir
yat.txt
$ ./bin/head -n 1 cut_data/data.spaces | ./bin/cut -f 2
world
$ ./bin/head -n 1 cut_data/data.csv | ./bin/cut -d , -f 1
hello
$ ./bin/head -n 1 cut_data/data.csv | ./bin/cut -d , -f 3
me
$ quit
+6
View File
@@ -0,0 +1,6 @@
$ which ./bin/rm
./bin/rm
$ which ./bin/cat
./bin/cat
$ quit
+18
View File
@@ -0,0 +1,18 @@
$ export A=5
$ ./bin/repeat 2 A
A=5
A=5
$ ./bin/env B=6 ./bin/repeat 1 A
A=5
$ ./bin/env C=10 ./bin/repeat 2 A 3 B 4 C
A=5
A=5
B=
B=
B=
C=10
C=10
C=10
C=10
$ quit
+9
View File
@@ -0,0 +1,9 @@
$ which export
export: dukesh built-in command
$ echo N=${NUM}
N=
$ export NUM=5
$ echo N=${NUM}
N=5
$ quit
+9
View File
@@ -0,0 +1,9 @@
$ export SHELL=/bin/bash
$ export USER=me
$ ./bin/repeat 1 USER
USER=me
$ ./bin/repeat 2 SHELL
SHELL=/bin/bash
SHELL=/bin/bash
$ quit
+13
View File
@@ -0,0 +1,13 @@
$ ./bin/ls data
empty.txt
FIRST.txt
pwd.txt
subdir
yat.txt
$ echo $?
0
$ ./bin/ls asldfkjasldfkj
$ echo $?
1
$ quit
+14
View File
@@ -0,0 +1,14 @@
$ ./bin/env A=5 ./bin/repeat 2 A
A=5
A=5
$ ./bin/env A=5 B=6 C=7 ./bin/repeat 1 A 2 B 3 C
A=5
B=6
B=6
C=7
C=7
C=7
$ ./bin/env A=10 ./bin/repeat 1 B
B=
$ quit
+14
View File
@@ -0,0 +1,14 @@
$ ./bin/ls data
empty.txt
FIRST.txt
pwd.txt
subdir
yat.txt
$ ./bin/head Makefile
#
# Simple Test Makefile
# Mike Lam, James Madison University, August 2016
#
# This version of the Makefile includes support for building a test suite. The
$ quit
@@ -0,0 +1,4 @@
$ ./bin/ls -l
$ ./bin/head -c 5 Makefile
$ quit
+6
View File
@@ -0,0 +1,6 @@
$ ./bin/ls -l
./bin/ls: invalid option -- 'l'
$ ./bin/head -c 5 Makefile
./bin/head: invalid option -- 'c'
$ quit
+35
View File
@@ -0,0 +1,35 @@
$ /usr/bin/chmod 751 data/subdir
$ /usr/bin/chmod 640 data/empty.txt
$ /usr/bin/chmod 640 data/FIRST.txt
$ /usr/bin/chmod 400 data/.hidden.txt
$ /usr/bin/chmod 640 data/pwd.txt
$ /usr/bin/chmod 640 data/yat.txt
$ ./bin/ls -a data
empty.txt
FIRST.txt
.hidden.txt
pwd.txt
subdir
yat.txt
$ ./bin/ls -s data
0 empty.txt
6 FIRST.txt
9 pwd.txt
22 yat.txt
$ ./bin/ls -sa data
0 empty.txt
6 FIRST.txt
5 .hidden.txt
9 pwd.txt
22 yat.txt
$ ./bin/ls -ap data
-rw-r----- empty.txt
-rw-r----- FIRST.txt
-r-------- .hidden.txt
-rw-r----- pwd.txt
drwxr-x--x subdir
-rw-r----- yat.txt
$ ./bin/head -n 1 Makefile
#
$ quit
+7
View File
@@ -0,0 +1,7 @@
$ cd /usr/bin
$ pwd
/usr/bin
$ which ls
/usr/bin/ls
$ quit
+35
View File
@@ -0,0 +1,35 @@
$ ./bin/ls -a data
empty.txt
FIRST.txt
.hidden.txt
pwd.txt
subdir
yat.txt
$ ./bin/ls -s data
0 empty.txt
6 FIRST.txt
9 pwd.txt
22 yat.txt
$ ./bin/ls -sa data
0 empty.txt
6 FIRST.txt
5 .hidden.txt
9 pwd.txt
22 yat.txt
$ ./bin/chmod rw- rw- --- data/empty.txt
$ ./bin/chmod r-- --- --x data/FIRST.txt
$ ./bin/chmod rw- rw- rw- data/pwd.txt
$ ./bin/chmod r-x r-x r-x data/yat.txt
$ ./bin/chmod rwx --- --- data/.hidden.txt
$ ./bin/chmod r-x --x r-- data/subdir
$ ./bin/ls -ap data
-rw-rw---- empty.txt
-r-------x FIRST.txt
-rwx------ .hidden.txt
-rw-rw-rw- pwd.txt
dr-x--xr-- subdir
-r-xr-xr-x yat.txt
$ ./bin/head -n 1 Makefile
#
$ quit
+17
View File
@@ -0,0 +1,17 @@
$ ./bin/cut cut_data/data.spaces
hello
later
$ ./bin/cut -f 2 cut_data/data.spaces
world
gator
$ ./bin/cut cut_data/data.csv
hello,world,me
later,gator
$ ./bin/cut -d , cut_data/data.csv
hello
later
$ ./bin/cut -d , -f 2 cut_data/data.csv
world
gator
$ quit
+15
View File
@@ -0,0 +1,15 @@
$ ./bin/cut -f -1 cut_data/data.spaces
cut, splits each line based on a delimiter
usage: cut [FLAG] FILE
FLAG can be:
-d C split each line based on the character C (default ' ')
-f N print the Nth field (1 is first, default 1)
If no FILE specified, read from STDIN
$ ./bin/cut -f 3 cut_data/data.spaces
me
$ ./bin/cut -d , -f 5 cut_data/data.csv
$ quit
+7
View File
@@ -0,0 +1,7 @@
$ echo goodbye
goodbye
$ echo hello\nworld
hello
world
$ quit
+8
View File
@@ -0,0 +1,8 @@
$ echo this has extra spaces
this has extra spaces
$ echo this\nhas\nnewlines
this
has
newlines
$ quit
+18
View File
@@ -0,0 +1,18 @@
$ which cd
cd: dukesh built-in command
$ which echo
echo: dukesh built-in command
$ which pwd
pwd: dukesh built-in command
$ which which
which: dukesh built-in command
$ which ./bin/ls
./bin/ls
$ which ./bin/head
./bin/head
$ which ls
/usr/bin/ls
$ which head
/usr/bin/head
$ quit
+6
View File
@@ -0,0 +1,6 @@
$ echo hello
hello
$ echo goodbye
goodbye
$ quit
+2
View File
@@ -0,0 +1,2 @@
$ quit
+95
View File
@@ -0,0 +1,95 @@
#!/bin/bash
# Ensure the data directory has 750 permissions
chmod 750 data
# Must run with env -i so that students cannot "accidentally" use the
# standard shell environment variables
EXE="env -i PATH=/usr/bin:. ../dukesh"
SKIP_C=""
SKIP_B=""
SKIP_A=""
function run_test {
# parameters
TAG=$1
ARGS=$2
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
$EXE $ARGS 2>/dev/null >"$OUTPUT"
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
valgrind $EXE $ARGS &>$VALGRND
}
# 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'`
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 | grep -v ' 0 bytes in 0 blocks' | sed -e 's/:.*$//g' | sed -e 's/^/ - /g'
fi
+40
View File
@@ -0,0 +1,40 @@
# 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
run_test D_quit "-b scripts/quit.txt"
run_test D_echo "-b scripts/echo_min.txt"
run_test C_cd_pwd "-b scripts/dirs.txt"
run_test C_echo "-b scripts/echo.txt"
run_test C_echo_space "-b scripts/echo_space.txt"
run_test C_binaries "-b scripts/bins.txt"
# Your ls implementation must list in alphabetical order
run_test C_binaries_flags "-b scripts/bins_flags.txt"
# Your ls must print directories (. and ..) first, then
# the rest in alphabetical order (ignoring leading . and case)
run_test C_chmod "-b scripts/bins_chmod.txt"
# Your ls must work correctly before chmod will work
run_test C_binaries_bad "-b scripts/bins_bad.txt"
run_test C_which "-b scripts/which.txt"
run_test C_cut "-b scripts/cut.txt"
run_test C_cut_bad "-b scripts/cut_bad.txt"
run_test B_return_code "-b scripts/rc.txt"
# Your ls implementation must list in alphabetical order
run_test B_export_unset "-b scripts/export.txt"
# Previous test exports and uses echo, no binaries
run_test B_repeat "-b scripts/repeat.txt"
# Previous test exports and uses repeat binary
run_test B_setenv "-b scripts/setenv.txt"
# Previous test uses ./bin/env to set env vars
run_test B_env "-b scripts/env.txt"
# Previous combines export and ./bin/env with ./bin/repeat
run_test A_cat_tail "-b scripts/tail.txt"
run_test A_pipe "-b scripts/pipe.txt"
run_test A_env "-b scripts/env_pipe.txt"
+114
View File
@@ -0,0 +1,114 @@
#include <check.h>
#include "../src/hash.h"
START_TEST (C_hash_insert)
{
char *strings[] = { "foo", "bar", "zoo", "yadda", "help", "goo", "hi", "boo",
"nine", "ten" };
hash_init (100);
for (int i = 0; i < 10; i++)
ck_assert (hash_insert (strings[i], strings[(i + 1) % 10]));
for (int i = 0; i < 10; i++)
{
char *value = hash_find (strings[i]);
ck_assert_str_eq (value, strings[(i + 1) % 10]);
}
}
END_TEST
START_TEST (C_hash_find_missing)
{
char *strings[] = { "foo", "bar", "zoo", "yadda", "help", "goo", "hi", "boo",
"nine", "ten" };
hash_init (100);
for (int i = 0; i < 10; i++)
ck_assert (hash_insert (strings[i], strings[(i + 1) % 10]));
ck_assert (hash_find ("gobble") == NULL);
}
END_TEST
START_TEST (C_hash_remove)
{
char *strings[] = { "foo", "bar", "zoo", "yadda", "help", "goo", "hi", "boo",
"nine", "ten" };
hash_init (100);
for (int i = 0; i < 10; i++)
ck_assert (hash_insert (strings[i], strings[(i + 1) % 10]));
for (int i = 0; i < 5; i++)
ck_assert (hash_remove (strings[i]));
ck_assert_str_eq (hash_find ("goo"), "hi");
for (int i = 5; i < 10; i++)
ck_assert (hash_remove (strings[i]));
ck_assert (hash_find ("goo") == NULL);
}
END_TEST
START_TEST (C_hash_replace)
{
char *strings[] = { "foo", "bar", "zoo", "yadda", "help", "goo", "hi", "boo",
"nine", "ten" };
hash_init (100);
for (int i = 0; i < 10; i++)
ck_assert (hash_insert (strings[i], strings[(i + 1) % 10]));
ck_assert (hash_insert ("yadda", "again?!"));
ck_assert_str_eq (hash_find ("yadda"), "again?!");
ck_assert (hash_insert ("yadda", "really?!"));
ck_assert_str_eq (hash_find ("yadda"), "really?!");
}
END_TEST
START_TEST (C_hash_collisions)
{
char *strings[] = { "foo", "bar", "zoo", "yadda", "help", "goo", "hi", "boo",
"nine", "ten" };
hash_init (100);
for (int i = 0; i < 10; i++)
ck_assert (hash_insert (strings[i], strings[(i + 1) % 10]));
ck_assert (hash_insert ("bar", "a"));
ck_assert (hash_insert ("help", "b"));
ck_assert_str_eq (hash_find ("bar"), "a");
ck_assert_str_eq (hash_find ("help"), "b");
ck_assert (hash_remove ("bar"));
ck_assert (hash_remove ("help"));
ck_assert (hash_find ("bar") == NULL);
ck_assert (hash_find ("help") == NULL);
ck_assert (hash_insert ("help", "asldasdffkj"));
ck_assert (hash_insert ("ten", "asldfkj"));
ck_assert_str_eq (hash_find ("help"), "asldasdffkj");
ck_assert_str_eq (hash_find ("ten"), "asldfkj");
}
END_TEST
void
public_tests (Suite *s)
{
TCase *tc_public = tcase_create ("Public");
tcase_add_test (tc_public, C_hash_insert);
tcase_add_test (tc_public, C_hash_find_missing);
tcase_add_test (tc_public, C_hash_remove);
tcase_add_test (tc_public, C_hash_replace);
tcase_add_test (tc_public, C_hash_collisions);
suite_add_tcase (s, tc_public);
}
+3
View File
@@ -0,0 +1,3 @@
./bin/ls data
./bin/head Makefile
quit
+3
View File
@@ -0,0 +1,3 @@
./bin/ls -l
./bin/head -c 5 Makefile
quit
+12
View File
@@ -0,0 +1,12 @@
./bin/ls -a data
./bin/ls -s data
./bin/ls -sa data
./bin/chmod rw- rw- --- data/empty.txt
./bin/chmod r-- --- --x data/FIRST.txt
./bin/chmod rw- rw- rw- data/pwd.txt
./bin/chmod r-x r-x r-x data/yat.txt
./bin/chmod rwx --- --- data/.hidden.txt
./bin/chmod r-x --x r-- data/subdir
./bin/ls -ap data
./bin/head -n 1 Makefile
quit
+12
View File
@@ -0,0 +1,12 @@
/usr/bin/chmod 751 data/subdir
/usr/bin/chmod 640 data/empty.txt
/usr/bin/chmod 640 data/FIRST.txt
/usr/bin/chmod 400 data/.hidden.txt
/usr/bin/chmod 640 data/pwd.txt
/usr/bin/chmod 640 data/yat.txt
./bin/ls -a data
./bin/ls -s data
./bin/ls -sa data
./bin/ls -ap data
./bin/head -n 1 Makefile
quit
+6
View File
@@ -0,0 +1,6 @@
./bin/cut cut_data/data.spaces
./bin/cut -f 2 cut_data/data.spaces
./bin/cut cut_data/data.csv
./bin/cut -d , cut_data/data.csv
./bin/cut -d , -f 2 cut_data/data.csv
quit
+4
View File
@@ -0,0 +1,4 @@
./bin/cut -f -1 cut_data/data.spaces
./bin/cut -f 3 cut_data/data.spaces
./bin/cut -d , -f 5 cut_data/data.csv
quit
+4
View File
@@ -0,0 +1,4 @@
cd /usr/bin
pwd
which ls
quit
+3
View File
@@ -0,0 +1,3 @@
echo goodbye
echo hello\nworld
quit
+3
View File
@@ -0,0 +1,3 @@
echo hello
echo goodbye
quit
+3
View File
@@ -0,0 +1,3 @@
echo this has extra spaces
echo this\nhas\nnewlines
quit
+5
View File
@@ -0,0 +1,5 @@
export A=5
./bin/repeat 2 A
./bin/env B=6 ./bin/repeat 1 A
./bin/env C=10 ./bin/repeat 2 A 3 B 4 C
quit
+5
View File
@@ -0,0 +1,5 @@
export A=5
./bin/env ./bin/repeat 1 A
./bin/env B=6 C=7 ./bin/repeat 1 A 2 B 3 C
./bin/env C=7 ./bin/repeat 1 A 2 B 3 C | head -n 4
quit
+5
View File
@@ -0,0 +1,5 @@
which export
echo N=${NUM}
export NUM=5
echo N=${NUM}
quit
+6
View File
@@ -0,0 +1,6 @@
./bin/ls -a data | ./bin/head -n 1
./bin/ls -a data | ./bin/head -n 2000
./bin/head -n 1 cut_data/data.spaces | ./bin/cut -f 2
./bin/head -n 1 cut_data/data.csv | ./bin/cut -d , -f 1
./bin/head -n 1 cut_data/data.csv | ./bin/cut -d , -f 3
quit
+1
View File
@@ -0,0 +1 @@
quit
+5
View File
@@ -0,0 +1,5 @@
./bin/ls data
echo $?
./bin/ls asldfkjasldfkj
echo $?
quit
+5
View File
@@ -0,0 +1,5 @@
export SHELL=/bin/bash
export USER=me
./bin/repeat 1 USER
./bin/repeat 2 SHELL
quit
+4
View File
@@ -0,0 +1,4 @@
./bin/env A=5 ./bin/repeat 2 A
./bin/env A=5 B=6 C=7 ./bin/repeat 1 A 2 B 3 C
./bin/env A=10 ./bin/repeat 1 B
quit
+4
View File
@@ -0,0 +1,4 @@
./bin/cat cut_data/data.csv
./bin/cat cut_data/data.csv | ./bin/cut -d , -f 2
./bin/cat cut_data/data.csv | tail -n 1
quit
+8
View File
@@ -0,0 +1,8 @@
echo N=${NUM}
export NUM=5
echo N=${NUM}
unset NUM
echo N=${NUM}
export NUM=10
echo N=${NUM}
quit
+9
View File
@@ -0,0 +1,9 @@
which cd
which echo
which pwd
which which
which ./bin/ls
which ./bin/head
which ls
which head
quit
+3
View File
@@ -0,0 +1,3 @@
which ./bin/rm
which ./bin/cat
quit
+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
+32
View File
@@ -0,0 +1,32 @@
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#include <time.h>
#include <check.h>
extern void public_tests (Suite *s);
Suite * test_suite (void)
{
Suite *s = suite_create ("Default");
public_tests (s);
return s;
}
void run_testsuite ()
{
Suite *s = test_suite ();
SRunner *sr = srunner_create (s);
srunner_run_all (sr, CK_NORMAL);
srunner_free (sr);
}
int main (void)
{
srand((unsigned)time(NULL));
run_testsuite ();
return EXIT_SUCCESS;
}