Removed submodules
This commit is contained in:
@@ -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=../sigs
|
||||
TEST=testsuite
|
||||
MODS=public.o
|
||||
OBJS=../signals.o ../child.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
|
||||
LDFLAGS=-g -O0
|
||||
|
||||
CFLAGS+=-I/opt/local/include -Wno-gnu-zero-variadic-macro-arguments
|
||||
LDFLAGS+=-L/opt/local/lib
|
||||
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
|
||||
|
||||
.PHONY: default clean test unittest inttest
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
6037b06b79a54f57617de151d505444f78a23489
|
||||
@@ -0,0 +1 @@
|
||||
ebef9658a6b46bd9cfcfeaf732a6d2444fe0b98a
|
||||
@@ -0,0 +1 @@
|
||||
145cbab85e3834cf39635245272d5f80e6bd66f2
|
||||
@@ -0,0 +1 @@
|
||||
b4ec94fbc4feb8f7ce089341bd6c51e775fce9e1
|
||||
@@ -0,0 +1 @@
|
||||
fb52530bd8b6756b4acec57a42391f8b7c9c0e83
|
||||
@@ -0,0 +1,3 @@
|
||||
I am the child
|
||||
Child exited with status 42
|
||||
I am the parent
|
||||
@@ -0,0 +1 @@
|
||||
Received bad signal name: KILL
|
||||
@@ -0,0 +1,3 @@
|
||||
Child has started
|
||||
Breaking out with signal 11
|
||||
Child was stopped with status 37
|
||||
@@ -0,0 +1,3 @@
|
||||
Child has started
|
||||
Breaking out with signal 2
|
||||
Child was stopped with status 37
|
||||
@@ -0,0 +1,3 @@
|
||||
I am the child
|
||||
Child exited with status 54
|
||||
I am the parent
|
||||
Executable
+75
@@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
|
||||
EXE="../procs"
|
||||
|
||||
function run_test {
|
||||
|
||||
# parameters
|
||||
TAG=$1
|
||||
ARGS=$2
|
||||
|
||||
# file paths
|
||||
OUTPUT=outputs/$TAG.txt
|
||||
DIFF=outputs/$TAG.diff
|
||||
EXPECT=expected/$TAG.txt
|
||||
VALGRND=valgrind/$TAG.txt
|
||||
|
||||
# print tag format
|
||||
PTAG=$(printf '%-30s' "$TAG")
|
||||
|
||||
# check for expected text that needs to be fixed
|
||||
if [ ! -z "$(egrep "<<<<.*>>>>" "$EXPECT")" ] ; then
|
||||
echo "$PTAG FAIL ($EXPECT not correct)"
|
||||
return
|
||||
fi
|
||||
|
||||
# compare the file
|
||||
SHAOUT=$(shasum "$EXPECT" | awk '{print $1}')
|
||||
SHAEXP=$(cat "expected/.$TAG.sha")
|
||||
if [ "$SHAOUT" != "$SHAEXP" ] ; then
|
||||
echo "$PTAG FAIL (expected file is not correct)"
|
||||
return
|
||||
fi
|
||||
|
||||
# run test and compare output to the expected version
|
||||
$EXE $ARGS 2>/dev/null >"$OUTPUT"
|
||||
diff -u "$OUTPUT" "$EXPECT" >"$DIFF"
|
||||
if [ -s "$DIFF" ]; then
|
||||
|
||||
# try alternative solution (if it exists)
|
||||
EXPECT=expected/$TAG-2.txt
|
||||
if [ -e "$EXPECT" ]; then
|
||||
diff -u "$OUTPUT" "$EXPECT" >"$DIFF"
|
||||
if [ -s "$DIFF" ]; then
|
||||
echo "$PTAG FAIL (see $DIFF for details)"
|
||||
else
|
||||
echo "$PTAG pass"
|
||||
fi
|
||||
else
|
||||
echo "$PTAG FAIL (see $DIFF for details)"
|
||||
fi
|
||||
else
|
||||
echo "$PTAG pass"
|
||||
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
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# 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 INTEG_child ""
|
||||
run_test INTEG_status "-e 54"
|
||||
run_test INTEG_sigint "-s INT"
|
||||
run_test INTEG_segfault "-s SEGV"
|
||||
run_test INTEG_kill "-s KILL"
|
||||
Binary file not shown.
@@ -0,0 +1,46 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <check.h>
|
||||
|
||||
#include "../signals.h"
|
||||
|
||||
START_TEST (UNIT_good_signals)
|
||||
{
|
||||
printf ("\n======================================\n");
|
||||
printf ("UNIT good signals\n");
|
||||
printf ("This test checks for signal name lookups\n");
|
||||
char *names[] = { "INT", "KILL", "SEGV", "TSTP" };
|
||||
int signals[] = { SIGINT, SIGKILL, SIGSEGV, SIGTSTP };
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
int sig = signal_lookup (names[i]);
|
||||
ck_assert_int_eq (signals[i], sig);
|
||||
}
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST (UNIT_bad_signals)
|
||||
{
|
||||
printf ("\n======================================\n");
|
||||
printf ("UNIT bad signals\n");
|
||||
printf ("This test checks for other signal name lookups\n");
|
||||
char *names[] = { "HUP", "ALRM", "ILL", "KIL" };
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
int sig = signal_lookup (names[i]);
|
||||
ck_assert_int_eq (sig, -1);
|
||||
}
|
||||
}
|
||||
END_TEST
|
||||
|
||||
void public_tests (Suite *s)
|
||||
{
|
||||
TCase *tc_public = tcase_create ("Public");
|
||||
tcase_add_test (tc_public, UNIT_good_signals);
|
||||
tcase_add_test (tc_public, UNIT_bad_signals);
|
||||
suite_add_tcase (s, tc_public);
|
||||
}
|
||||
|
||||
Executable
+53
@@ -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 ../*.c ../*.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
|
||||
@@ -0,0 +1,34 @@
|
||||
#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);
|
||||
//extern void private_tests (Suite *s);
|
||||
|
||||
Suite * test_suite (void)
|
||||
{
|
||||
Suite *s = suite_create ("Default");
|
||||
public_tests (s);
|
||||
//private_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;
|
||||
}
|
||||
Reference in New Issue
Block a user