Permalink
Browse files

first commit

  • Loading branch information...
txus committed Oct 3, 2012
1 parent 18b7253 commit ecbaba1d010e09ca30b8b4a9018d1bc261b8dee5
Showing with 27 additions and 111 deletions.
  1. +2 −1 .gitignore
  2. +2 −2 Makefile
  3. +0 −43 src/lib.c
  4. 0 src/{ → staat}/dbg.h
  5. +1 −0 src/staat/staat.c
  6. +4 −0 src/staat/staat.h
  7. +0 −64 tests/lib_tests.c
  8. +1 −1 tests/minunit.h
  9. +17 −0 tests/staat_tests.c
View
@@ -1,4 +1,5 @@
build
*.o
tests/*_tests
-tests/tests.log
+tests/tests.log
+*.DSYM
View
@@ -1,4 +1,4 @@
-CFLAGS=-g -O2 -Wall -Wextra -Isrc -rdynamic -DNDEBUG $(OPTFLAGS)
+CFLAGS=-g -O2 -Wall -Wextra -Isrc -DNDEBUG $(OPTFLAGS)
LIBS=-ldl $(OPTLIBS)
PREFIX?=/usr/local
@@ -8,7 +8,7 @@ OBJECTS=$(patsubst %.c,%.o,$(SOURCES))
TEST_SRC=$(wildcard tests/*_tests.c)
TESTS=$(patsubst %.c,%,$(TEST_SRC))
-TARGET=build/libYOUR_LIBRARY.a
+TARGET=build/libstaat.a
SO_TARGET=$(patsubst %.a,%.so,$(TARGET))
# The Target Build
View
@@ -1,43 +0,0 @@
-#include <stdio.h>
-#include <ctype.h>
-#include "dbg.h"
-
-int print_a_message(const char *msg)
-{
- printf("A STRING: %s\n", msg);
-
- return 0;
-}
-
-int uppercase(const char *msg)
-{
- int i = 0;
-
- // BUG: \0 termination problems
- for(i = 0; msg[i] != '\0'; i++) {
- printf("%c", toupper(msg[i]));
- }
-
- printf("\n");
-
- return 0;
-}
-
-int lowercase(const char *msg)
-{
- int i = 0;
-
- // BUG: \0 termination problems
- for(i = 0; msg[i] != '\0'; i++) {
- printf("%c", tolower(msg[i]));
- }
-
- printf("\n");
-
- return 0;
-}
-
-int fail_on_purpose(const char *msg)
-{
- return 1;
-}
File renamed without changes.
View
@@ -0,0 +1 @@
+#include <staat/staat.h>
View
@@ -0,0 +1,4 @@
+#ifndef __staat_h__
+#define __staat_h__
+
+#endif
View
@@ -1,64 +0,0 @@
-#include "minunit.h"
-#include <dlfcn.h>
-
-typedef int (*lib_function)(const char *data);
-char *lib_file = "build/libYOUR_LIBRARY.so";
-void *lib = NULL;
-
-int check_function(const char *func_to_run, const char *data, int expected)
-{
- lib_function func = dlsym(lib, func_to_run);
- check(func != NULL, "Did not find %s function in the library %s: %s", func_to_run, lib_file, dlerror());
-
- int rc = func(data);
- check(rc == expected, "Function %s return %d for data: %s", func_to_run, rc, data);
-
- return 1;
-error:
- return 0;
-}
-
-char *test_dlopen()
-{
- lib = dlopen(lib_file, RTLD_NOW);
- mu_assert(lib != NULL, "Failed to open the library to test.");
-
- return NULL;
-}
-
-char *test_functions()
-{
- mu_assert(check_function("print_a_message", "Hello", 0), "print_a_message failed.");
- mu_assert(check_function("uppercase", "Hello", 0), "uppercase failed.");
- mu_assert(check_function("lowercase", "Hello", 0), "lowercase failed.");
-
- return NULL;
-}
-
-char *test_failures()
-{
- mu_assert(check_function("fail_on_purpose", "Hello", 1), "fail_on_purpose should fail.");
-
- return NULL;
-}
-
-char *test_dlclose()
-{
- int rc = dlclose(lib);
- mu_assert(rc == 0, "Failed to close lib.");
-
- return NULL;
-}
-
-char *all_tests() {
- mu_suite_start();
-
- mu_run_test(test_dlopen);
- mu_run_test(test_functions);
- mu_run_test(test_failures);
- mu_run_test(test_dlclose);
-
- return NULL;
-}
-
-RUN_TESTS(all_tests);
View
@@ -3,7 +3,7 @@
#define _minunit_h
#include <stdio.h>
-#include <dbg.h>
+#include <staat/dbg.h>
#include <stdlib.h>
#define mu_suite_start() char *message = NULL
View
@@ -0,0 +1,17 @@
+#include "minunit.h"
+#include <staat/staat.h>
+
+char *test_foo()
+{
+ return NULL;
+}
+
+char *all_tests() {
+ mu_suite_start();
+
+ mu_run_test(test_foo);
+
+ return NULL;
+}
+
+RUN_TESTS(all_tests);

0 comments on commit ecbaba1

Please sign in to comment.