summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--.gitmodules6
-rw-r--r--.travis.yml11
-rw-r--r--CHANGELOG.mkd5
-rw-r--r--LICENSE24
-rw-r--r--Makefile39
-rw-r--r--README.mkd20
m---------deps/bitfield-c6
m---------deps/isotp-c6
-rw-r--r--runtests.sh17
-rw-r--r--tests/tests.c37
11 files changed, 175 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b4225c0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+*.o
+.DS_Store
+*~
+*.bin
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..d9c0194
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,6 @@
+[submodule "deps/bitfield-c"]
+ path = deps/bitfield-c
+ url = https://github.com/openxc/bitfield-c
+[submodule "deps/isotp-c"]
+ path = deps/isotp-c
+ url = https://github.com/openxc/isotp-c
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..22b1a91
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,11 @@
+language: c
+compiler:
+ - gcc
+script: make test
+before_install:
+ - git submodule update --init
+ - sudo apt-get update -qq
+ - sudo apt-get install check
+notifications:
+ hipchat:
+ - secure: "ZO/hEAoOTZ4FJytMW0m4LZrsdFVM1/V0Hu13zfj8mdcHkf2MyfxthPDecnn5\naZVn4P8mSSwpp39EnAfa9fBcWcDESnKM1YQKPPGkoxZZHIOd2rYhRv34XfpE\n5qNLkQ/lEPQCBEmvIQ5ZJxsiZjGhO7KxWvdNdruH6cdVCYSh4Xo="
diff --git a/CHANGELOG.mkd b/CHANGELOG.mkd
new file mode 100644
index 0000000..edf7f7d
--- /dev/null
+++ b/CHANGELOG.mkd
@@ -0,0 +1,5 @@
+# OBD-II Support Library in C
+
+## v0.1
+
+* Initial release
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..330d61f
--- /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 0000000..9873038
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,39 @@
+CC = gcc
+INCLUDES = -Isrc -Ideps/bitfield-c/src -Ideps/isotp-c/src
+CFLAGS = $(INCLUDES) -c -w -Wall -Werror -g -ggdb -std=c99
+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)
+SRC += $(wildcard deps/bitfield-c/src/**/*.c)
+SRC += $(wildcard deps/isotp-c/src/**/*.c)
+OBJS = $(SRC:.c=.o)
+TEST_SRC = $(wildcard $(TEST_DIR)/test_*.c)
+TESTS=$(patsubst %.c,%.bin,$(TEST_SRC))
+TEST_SUPPORT_SRC = $(TEST_DIR)/common.c
+TEST_SUPPORT_OBJS = $(TEST_SUPPORT_SRC:.c=.o)
+
+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) $(TEST_SUPPORT_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 0000000..485f2cc
--- /dev/null
+++ b/README.mkd
@@ -0,0 +1,20 @@
+OBD-II Support Library in C
+=============================
+
+## API
+
+## 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/deps/bitfield-c b/deps/bitfield-c
new file mode 160000
+Subproject cd74b88432054107c439c4e565bea14840dd9ea
diff --git a/deps/isotp-c b/deps/isotp-c
new file mode 160000
+Subproject 368d36cc15b69882e9d21803f3b8aa7a1c97736
diff --git a/runtests.sh b/runtests.sh
new file mode 100644
index 0000000..4781636
--- /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 0000000..6874565
--- /dev/null
+++ b/tests/tests.c
@@ -0,0 +1,37 @@
+#include <check.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+void setup() {
+
+}
+
+START_TEST (test_fail)
+{
+ fail_unless(false);
+}
+END_TEST
+
+Suite* testSuite(void) {
+ Suite* s = suite_create("obd2");
+ TCase *tc_core = tcase_create("core");
+ tcase_add_checked_fixture(tc_core, setup, NULL);
+ tcase_add_test(tc_core, test_fail);
+ suite_add_tcase(s, tc_core);
+
+ return s;
+}
+
+int main(void) {
+ int numberFailed;
+ Suite* s = testSuite();
+ 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;
+}