diff options
author | Mike Harsch <mike@harschsystems.com> | 2012-10-22 16:44:57 -0600 |
---|---|---|
committer | Mike Harsch <mike@harschsystems.com> | 2012-10-22 16:44:57 -0600 |
commit | dfb9587ea397fcdca0c69732624a2ed84062c7de (patch) | |
tree | b644b6cd2cce83291bb95fd74219db0dd48343db | |
parent | afb1582fed8039640805d5b64c9b46a6d82d296b (diff) | |
download | libnvpair-dfb9587ea397fcdca0c69732624a2ed84062c7de.tar.gz |
add simple test
-rw-r--r-- | test/Makefile | 27 | ||||
-rw-r--r-- | test/hello_nv.c | 19 |
2 files changed, 46 insertions, 0 deletions
diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..8ac15dc --- /dev/null +++ b/test/Makefile @@ -0,0 +1,27 @@ +CC = /usr/bin/gcc +DEBUG_FLAGS = -g +WARN_FLAGS = -Wall +PIC_FLAGS = -fPIC +OPT_FLAGS = -O2 +C_STDFLAGS = -std=c99 +INC_FLAGS = -I.. + +CFLAGS = $(DEBUG_FLAGS) \ + $(WARN_FLAGS) \ + $(PIC_FLAGS) \ + $(OPT_FLAGS) \ + $(C_STDFLAGS) \ + $(INC_FLAGS) + +STD_DEFS = -D_GNU_SOURCE -D__EXTENSION__ +LF64_DEFS = -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 +PIC_DEFS = -DPIC + +CPPFLAGS = $(STD_DEFS) $(LF64_DEFS) $(PIC_DEFS) + + +hellonv: hello_nv.c + $(CC) $(CPPFLAGS) $(CFLAGS) -o hello_nv hello_nv.c ../libnvpair.a + +clean: + rm -f $(OBJS) hello_nv diff --git a/test/hello_nv.c b/test/hello_nv.c new file mode 100644 index 0000000..c467405 --- /dev/null +++ b/test/hello_nv.c @@ -0,0 +1,19 @@ +#include <stdio.h> +#include "../libnvpair.h" + +int +main() { + char *cp; + nvlist_t *lp; + + nvlist_alloc(&lp, NV_UNIQUE_NAME, 0); + + nvlist_add_string(lp, "foo", "bar"); + + nvlist_lookup_string(lp, "foo", &cp); + + printf("value of foo is: %s\n", cp); + + nvlist_free(lp); + return (0); +} |