Add test case plus make changes so test case runs
authorbdemsky <bdemsky@uci.edu>
Thu, 22 Jun 2017 19:11:28 +0000 (12:11 -0700)
committerbdemsky <bdemsky@uci.edu>
Thu, 22 Jun 2017 19:11:28 +0000 (12:11 -0700)
14 files changed:
src/Collections/array.h
src/Collections/structs.c
src/Collections/structs.h
src/Makefile
src/Test/.buildconstraints.d [new file with mode: 0644]
src/Test/Makefile [new file with mode: 0644]
src/Test/buildconstraints [new file with mode: 0755]
src/Test/buildconstraints.c [new file with mode: 0644]
src/Test/buildconstraints.dSYM/Contents/Info.plist [new file with mode: 0644]
src/Test/buildconstraints.dSYM/Contents/Resources/DWARF/buildconstraints [new file with mode: 0644]
src/Test/run.sh [new file with mode: 0755]
src/common.h
src/csolver.h
src/mymemory.h

index d0841587608bfb792a2d0b412499e9138938c801..73d0c32124a7cb873724179c2001aeeaa90103e4 100644 (file)
@@ -7,41 +7,41 @@
                uint size;                                                                                                                                                                                                                                      \
        };                                                                    \
        typedef struct Array ## name Array ## name;                                                                                                             \
-       inline Array ## name * allocArray ## name(uint size) {                                                          \
+       static inline Array ## name * allocArray ## name(uint size) {                                                           \
                Array ## name * tmp = (Array ## name *)ourmalloc(sizeof(type));                 \
                tmp->size = size;                                                                                                                                                                                                               \
                tmp->array = (type *) ourcalloc(1, sizeof(type) * size);                                                \
                return tmp;                                                         \
        }                                                                     \
-       inline Array ## name * allocArrayInit ## name(type * array, uint size)  { \
+       static inline Array ## name * allocArrayInit ## name(type * array, uint size)  { \
                Array ## name * tmp = allocArray ## name(size);                                                                                 \
                memcpy(tmp->array, array, size * sizeof(type));                                                                                 \
                return tmp;                                                         \
        }                                                                     \
-       inline type getArray ## name(Array ## name * This, uint index) {                        \
+       static inline type getArray ## name(Array ## name * This, uint index) {                 \
                return This->array[index];                                                                                                                                                                      \
        }                                                                     \
-       inline void setArray ## name(Array ## name * This, uint index, type item) {     \
+       static inline void setArray ## name(Array ## name * This, uint index, type item) {      \
                This->array[index]=item;                                                                                                                                                                                \
        }                                                                     \
-       inline uint getSizeArray ## name(Array ## name *This) {                                                         \
+       static inline uint getSizeArray ## name(Array ## name *This) {                                                          \
                return This->size;                                                                                                                                                                                                      \
        }                                                                     \
-       inline void deleteArray ## name(Array ## name *This) {                                                          \
+       static inline void deleteArray ## name(Array ## name *This) {                                                           \
                ourfree(This->array);                                                                                                                                                                                           \
                ourfree(This);                                                                                                                                                                                                                  \
        }                                                                     \
-       inline type * exposeCArray ## name(Array ## name * This) {                                                      \
+       static inline type * exposeCArray ## name(Array ## name * This) {                                                       \
                return This->array;                                                                                                                                                                                                     \
        }                                                                                                                                                                                                                                                                                       \
-       inline void deleteInlineArray ## name(Array ## name *This) {                                    \
+       static inline void deleteInlineArray ## name(Array ## name *This) {                                     \
                ourfree(This->array);                                                                                                                                                                                           \
        }                                                                                                                                                                                                                                                                                       \
-       inline void allocInlineArray ## name(Array ## name * This, uint size) {                 \
+       static inline void allocInlineArray ## name(Array ## name * This, uint size) {                  \
                This->size = size;                                                                                                                                                                                                      \
                This->array = (type *) ourcalloc(1, sizeof(type) * size);                                               \
        }                                                                                                                                                                                                                                                                                       \
-       inline void allocInlineArrayInit ## name(Array ## name * This, type *array, uint size) { \
+       static inline void allocInlineArrayInit ## name(Array ## name * This, type *array, uint size) { \
                allocInlineArray ##name(This, size);                                                                                                                            \
                memcpy(This->array, array, size * sizeof(type));                                                                                \
        }
index 4da4995028eb8458b5087757bae2eabc17754f5a..f7768303a356e299ae3d08ee3d84b4b10c23e8ec 100644 (file)
@@ -1,11 +1,14 @@
 #include "structs.h"
 #include "mymemory.h"
 
-VectorImpl(Int, uint64_t, 4);
+VectorImpl(Table, Table *, 4);
+VectorImpl(Set, Set *, 4);
 VectorImpl(Boolean, Boolean *, 4);
 VectorImpl(Constraint, Constraint *, 4);
-VectorImpl(Set, Set *, 4);
+VectorImpl(Function, Function *, 4);
+VectorImpl(Predicate, Predicate *, 4);
 VectorImpl(Element, Element *, 4);
+VectorImpl(Order, Order *, 4);
+VectorImpl(TableEntry, TableEntry *, 4);
 VectorImpl(ASTNode, ASTNode *, 4);
-HashTableImpl(Void, void *, void *, Ptr_hash_function, Ptr_equals);
-HashSetImpl(Void, void *, Ptr_hash_function, Ptr_equals);
+VectorImpl(Int, uint64_t, 4);
index 71ba4b0f94161a515cbe26ffa88084ff3e97b33f..fec9d75cc539b3e256fc34781266a8183ddbfead 100644 (file)
@@ -9,17 +9,19 @@
 ArrayDef(Element, Element *);
 ArrayDef(Boolean, Boolean *);
 ArrayDef(Set, Set *);
-VectorDef(Int, uint64_t, 4);
+
+VectorDef(Table, Table *, 4);
+VectorDef(Set, Set *, 4);
 VectorDef(Boolean, Boolean *, 4);
 VectorDef(Constraint, Constraint *, 4);
-VectorDef(Set, Set *, 4);
-VectorDef(Element, Element *, 4);
-VectorDef(TableEntry, TableEntry *, 4);
+VectorDef(Function, Function *, 4);
 VectorDef(Predicate, Predicate *, 4);
-VectorDef(Table, Table *, 4);
+VectorDef(Element, Element *, 4);
 VectorDef(Order, Order *, 4);
-VectorDef(Function, Function *, 4);
+VectorDef(TableEntry, TableEntry *, 4);
 VectorDef(ASTNode, ASTNode *, 4);
+VectorDef(Int, uint64_t, 4);
+
 
 inline unsigned int Ptr_hash_function(void * hash) {
        return (unsigned int)((uint64_t)hash >> 4);
@@ -29,6 +31,5 @@ inline bool Ptr_equals(void * key1, void * key2) {
        return key1 == key2;
 }
 
-HashTableDef(Void, void *, void *, Ptr_hash_function, Ptr_equals);
-HashSetDef(Void, void *, Ptr_hash_function, Ptr_equals);
+
 #endif
index 1c4d358a65080ad4ea14edd08d614f9bac9b653e..35468a08a24ab9c3dc1e1c3f3c1d32a3712f4653 100644 (file)
@@ -37,6 +37,9 @@ ${OBJ_DIR}:
 debug: CFLAGS += -DCONFIG_DEBUG
 debug: all
 
+test: all
+       make -C Test
+
 PHONY += docs
 docs: $(C_SOURCES) $(HEADERS)
        doxygen
diff --git a/src/Test/.buildconstraints.d b/src/Test/.buildconstraints.d
new file mode 100644 (file)
index 0000000..836415d
--- /dev/null
@@ -0,0 +1,4 @@
+buildconstraints: buildconstraints.c ../csolver.h ../classlist.h \
+  ../mymemory.h ../config.h ../AST/ops.h ../Collections/structs.h \
+  ../Collections/vector.h ../Collections/hashtable.h ../common.h \
+  ../Collections/hashset.h ../Collections/array.h
diff --git a/src/Test/Makefile b/src/Test/Makefile
new file mode 100644 (file)
index 0000000..ca9a632
--- /dev/null
@@ -0,0 +1,19 @@
+BASE := ..
+
+OBJECTS := $(patsubst %.c, %, $(wildcard *.c))
+
+include $(BASE)/common.mk
+
+DEPS := $(join $(addsuffix ., $(dir $(OBJECTS))), $(addsuffix .d, $(notdir $(OBJECTS))))
+
+CPPFLAGS += -I$(BASE) -I$(BASE)/AST -I$(BASE)/Collections
+
+all: $(OBJECTS)
+
+-include $(DEPS)
+
+%: %.c
+       $(CC) -MMD -MF $(@D)/.$(@F).d -o $@ $< $(CPPFLAGS) -L$(BASE)/bin/ -l_cons_comp
+
+clean::
+       rm -f $(OBJECTS) $(DEPS)
diff --git a/src/Test/buildconstraints b/src/Test/buildconstraints
new file mode 100755 (executable)
index 0000000..92eefcc
Binary files /dev/null and b/src/Test/buildconstraints differ
diff --git a/src/Test/buildconstraints.c b/src/Test/buildconstraints.c
new file mode 100644 (file)
index 0000000..ef6ea46
--- /dev/null
@@ -0,0 +1,15 @@
+#include "csolver.h"
+
+int main(int numargs, char ** argv) {
+       CSolver * solver=allocCSolver();
+       uint64_t set1[]={0, 1, 2};
+       Set * s=createSet(solver, 0, set1, 3);
+       Element * e1=getElementVar(solver, s);
+       Element * e2=getElementVar(solver, s);
+       Set * domain[]={s, s};
+       Predicate *equals=createPredicateOperator(solver, EQUALS, domain, 2);
+       Element * inputs[]={e1, e2};
+       Boolean * b=applyPredicate(solver, equals, inputs, 2);
+       addBoolean(solver, b);
+       deleteSolver(solver);
+}
diff --git a/src/Test/buildconstraints.dSYM/Contents/Info.plist b/src/Test/buildconstraints.dSYM/Contents/Info.plist
new file mode 100644 (file)
index 0000000..737bf4f
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+       <dict>
+               <key>CFBundleDevelopmentRegion</key>
+               <string>English</string>
+               <key>CFBundleIdentifier</key>
+               <string>com.apple.xcode.dsym.buildconstraints</string>
+               <key>CFBundleInfoDictionaryVersion</key>
+               <string>6.0</string>
+               <key>CFBundlePackageType</key>
+               <string>dSYM</string>
+               <key>CFBundleSignature</key>
+               <string>????</string>
+               <key>CFBundleShortVersionString</key>
+               <string>1.0</string>
+               <key>CFBundleVersion</key>
+               <string>1</string>
+       </dict>
+</plist>
diff --git a/src/Test/buildconstraints.dSYM/Contents/Resources/DWARF/buildconstraints b/src/Test/buildconstraints.dSYM/Contents/Resources/DWARF/buildconstraints
new file mode 100644 (file)
index 0000000..d4eacfc
Binary files /dev/null and b/src/Test/buildconstraints.dSYM/Contents/Resources/DWARF/buildconstraints differ
diff --git a/src/Test/run.sh b/src/Test/run.sh
new file mode 100755 (executable)
index 0000000..9741fe0
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+export LD_LIBRARY_PATH=../bin
+# For Mac OSX
+export DYLD_LIBRARY_PATH=../bin
+
+$@
index 9b7848583f0eebd17bb0c23303af3dfb2590c4fb..d9e6d4346dc525e00fa8d676080bc577cdbeab46 100644 (file)
@@ -17,6 +17,7 @@
 #include <stdio.h>
 #include "config.h"
 
+/*
 extern int model_out;
 extern int model_err;
 extern int switch_alloc;
@@ -27,6 +28,10 @@ extern int switch_alloc;
 
 #define model_print_err(fmt, ...) do { model_dprintf(model_err, fmt, ## __VA_ARGS__); } while (0)
 
+*/
+
+#define model_print printf
+
 #define NEXTPOW2(x) (1<<(sizeof(uint)*8-__builtin_clz(x-1)))
 
 #ifdef CONFIG_DEBUG
index 95809dda5b7bb5db420feee6ce23824313b8592f..495d3864dca23ebdca90cab1f7eec52f485e3fa2 100644 (file)
@@ -34,6 +34,10 @@ struct CSolver {
 
 CSolver * allocCSolver();
 
+/** Delete solver instance. */
+
+void deleteSolver(CSolver * This);
+
 /** This function creates a set containing the elements passed in the array. */
 
 Set * createSet(CSolver *, VarType type, uint64_t * elements, uint num);
index 2fa964e6f8031779d21f958f2ae2a2b71d3c3f79..32dfa51b51e8807f6c906ff64d585f08ba099835 100644 (file)
 
 #include "config.h"
 
+/*
 void * ourmalloc(size_t size);
 void ourfree(void *ptr);
 void * ourcalloc(size_t count, size_t size);
 void * ourrealloc(void *ptr, size_t size);
+*/
+
+static inline void * ourmalloc(size_t size) { return malloc(size); }
+static inline void ourfree(void *ptr) { free(ptr); }
+static inline void * ourcalloc(size_t count, size_t size) { return calloc(count, size); }
+static inline void * ourrealloc(void *ptr, size_t size) { return realloc(ptr, size); }
 
 #endif/* _MY_MEMORY_H */