summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.mkd5
-rw-r--r--LICENSE24
-rw-r--r--Makefile36
-rw-r--r--README.mkd18
-rw-r--r--runtests.sh17
-rw-r--r--tests/tests.c30
6 files changed, 130 insertions, 0 deletions
diff --git a/CHANGELOG.mkd b/CHANGELOG.mkd
new file mode 100644
index 00000000..e7090942
--- /dev/null
+++ b/CHANGELOG.mkd
@@ -0,0 +1,5 @@
+# ISO 15765-2 Support Library in C
+
+## v0.1
+
+* Initial release
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 00000000..330d61f4
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,24 @@
+Copyright (c) 2013 Ford Motor Company
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the <organization> nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..49e22f2c
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,36 @@
+CC = gcc
+INCLUDES = -Isrc
+CFLAGS = $(INCLUDES) -c -w -Wall -Werror -g -ggdb
+LDFLAGS =
+LDLIBS = -lcheck
+
+TEST_DIR = tests
+
+# Guard against \r\n line endings only in Cygwin
+OSTYPE := $(shell uname)
+ifneq ($(OSTYPE),Darwin)
+ OSTYPE := $(shell uname -o)
+ ifeq ($(OSTYPE),Cygwin)
+ TEST_SET_OPTS = igncr
+ endif
+endif
+
+SRC = $(wildcard src/**/*.c)
+OBJS = $(SRC:.c=.o)
+TEST_SRC = $(wildcard $(TEST_DIR)/*.c)
+TEST_OBJS = $(TEST_SRC:.c=.o)
+TESTS=$(patsubst %.c,%.bin,$(TEST_SRC))
+
+all: $(OBJS)
+
+test: $(TESTS)
+ @set -o $(TEST_SET_OPTS) >/dev/null 2>&1
+ @export SHELLOPTS
+ @sh runtests.sh $(TEST_DIR)
+
+$(TEST_DIR)/%.bin: $(TEST_DIR)/%.o $(OBJS)
+ @mkdir -p $(dir $@)
+ $(CC) $(LDFLAGS) $(CC_SYMBOLS) $(INCLUDES) -o $@ $^ $(LDLIBS)
+
+clean:
+ rm -rf **/*.o $(TEST_DIR)/*.bin
diff --git a/README.mkd b/README.mkd
new file mode 100644
index 00000000..a8497071
--- /dev/null
+++ b/README.mkd
@@ -0,0 +1,18 @@
+ISO 15765-2 Support Library in C
+============
+
+## Testing
+
+The library includes a test suite that uses the `check` C unit test library.
+
+ $ make test
+
+## Authors
+
+Chris Peplin cpeplin@ford.com
+
+## License
+
+Copyright (c) 2013 Ford Motor Company
+
+Licensed under the BSD license.
diff --git a/runtests.sh b/runtests.sh
new file mode 100644
index 00000000..4781636b
--- /dev/null
+++ b/runtests.sh
@@ -0,0 +1,17 @@
+echo "Running unit tests:"
+
+for i in $1/*.bin
+do
+ if test -f $i
+ then
+ if ./$i
+ then
+ echo $i PASS
+ else
+ echo "ERROR in test $i:"
+ exit 1
+ fi
+ fi
+done
+
+echo "${txtbld}$(tput setaf 2)All unit tests passed.$(tput sgr0)"
diff --git a/tests/tests.c b/tests/tests.c
new file mode 100644
index 00000000..62b3df8d
--- /dev/null
+++ b/tests/tests.c
@@ -0,0 +1,30 @@
+#include <check.h>
+#include <stdint.h>
+#include <bitfield/bitfield.h>
+
+START_TEST (test_fail)
+{
+ fail_if(true);
+}
+END_TEST
+
+Suite* bitfieldSuite(void) {
+ Suite* s = suite_create("iso15765");
+ TCase *tc_core = tcase_create("core");
+ tcase_add_test(tc_core, test_fail);
+ suite_add_tcase(s, tc_core);
+
+ return s;
+}
+
+int main(void) {
+ int numberFailed;
+ Suite* s = bitfieldSuite();
+ SRunner *sr = srunner_create(s);
+ // Don't fork so we can actually use gdb
+ srunner_set_fork_status(sr, CK_NOFORK);
+ srunner_run_all(sr, CK_NORMAL);
+ numberFailed = srunner_ntests_failed(sr);
+ srunner_free(sr);
+ return (numberFailed == 0) ? 0 : 1;
+}