summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/.gitignore2
-rw-r--r--test/Makefile9
-rw-r--r--test/exp1.c21
-rw-r--r--test/test1.c172
4 files changed, 204 insertions, 0 deletions
diff --git a/test/.gitignore b/test/.gitignore
new file mode 100644
index 0000000..92746d2
--- /dev/null
+++ b/test/.gitignore
@@ -0,0 +1,2 @@
+log.txt
+test1
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..f1e1388
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,9 @@
+CC=g++
+CFLAGS=-g3 -fno-rtti -fno-exceptions -fno-unwind-tables
+
+make:
+ g++ -c test1.c
+ gcc $(CFLAGS) test1.o ../arg.o -o test1
+
+leak:
+ valgrind --leak-check=full --track-origins=yes --log-file=log.txt ./test1 -d "ads|asd|asd" \ No newline at end of file
diff --git a/test/exp1.c b/test/exp1.c
new file mode 100644
index 0000000..8488e9b
--- /dev/null
+++ b/test/exp1.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+typedef struct s
+{
+ int num;
+ char **val;
+} s;
+
+char *list1[] = {"asd","asd"};
+
+s def1[] =
+{
+ {1,list1}
+};
+
+int main()
+{
+
+ return 0;
+} \ No newline at end of file
diff --git a/test/test1.c b/test/test1.c
new file mode 100644
index 0000000..d87443f
--- /dev/null
+++ b/test/test1.c
@@ -0,0 +1,172 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+
+#include "../arg.h"
+
+//define ip4 127.0.0.1:8080
+/*
+s_arg_ip src_ip =
+{
+ port:8080,
+ .ip = 0x7f000001,
+ .result = NULL
+};
+*/
+
+
+/*
+//?
+//frequency range from 88:108
+s_arg_range freq_range =
+{
+ .start = 88,
+ .end = 108,
+ .step = 100e3,
+ .result = NULL
+};
+*/
+
+/*
+s_arg_float ratio_float =
+{
+ .val = 0.8,
+ .result = NULL
+};
+*/
+
+
+
+/*
+char *color_list[] = {"RED","GREEN","BLUE"};
+
+s_arg_list color_name_list =
+{
+ .num = 3,
+ .default_val = "RED",
+ .vals = color_list,
+ .result = NULL
+};
+*/
+
+/*
+s_arg_val number_val =
+{
+ .ptr = NULL,
+ .default_ptr = "None",
+ .result = NULL
+};
+*/
+
+/*
+s_arg_flag flag_help =
+{
+ .used = 0,
+ .result = NULL
+};
+*/
+
+/*
+//cant be const
+def_arg cmd_arg[] =
+{
+ ARG_ENTRY("-a",IP, &src_ip,"test ip address argument"),
+ ARG_ENTRY("-b",RANGE,&freq_range,"test integer range argument"),
+ ARG_ENTRY("-c",FLOAT,&ratio_float,"test float number"),
+ ARG_ENTRY("-d",LIST, &color_name_list,"check list of values"),
+ ARG_ENTRY("-e",VAL, &number_val,"string number values"),
+ ARG_ENTRY("-f",FILE, NULL,"check file argument"),
+ ARG_ENTRY("-g",FLAG, &flag_help,"check flag argument"),
+ {NULL,0,NULL}
+};
+*/
+
+extern "C" void* emulate_cc_new(unsigned len) { \
+ printf("New allocated\n");
+ void *p = malloc(len);
+ if (p == 0) {
+ /* Don't use stdio (e.g. fputs), because that may want to allocate more
+ * memory.
+ */
+ (void)!write(2, "out of memory\n", 14);
+ abort();
+ }
+ return p;
+}
+extern "C" void emulate_cc_delete(void* p) {
+ if (p != 0)
+ free(p);
+}
+void* operator new(long unsigned int len) __attribute__((alias("emulate_cc_new")));
+void* operator new[](long unsigned int len) __attribute__((alias("emulate_cc_new")));
+void operator delete(void* p, unsigned long len) __attribute__((alias("emulate_cc_delete")));
+void operator delete[](void* p, unsigned long len) __attribute__((alias("emulate_cc_delete")));
+void* __cxa_pure_virtual = 0;
+__gxx_personality_v0
+
+#include "../arg.h"
+
+int main( int argc, char **argv )
+{
+
+ /*
+ int i=0;
+ arg_t *cfg = NULL;
+
+ i = 0;
+ while ( cmd_arg[i].param != NULL )
+ {
+ printf("%s - %s\n",cmd_arg[i].param, cmd_arg[i].help);
+ i++;
+ }
+
+ cfg = arg_load( argc, argv, cmd_arg );
+
+ if (cfg->size == 0)
+ {
+ printf("No arguments found\n");
+ //goto exit_error;
+ }
+
+ for (i=0;i<cfg->size;i++)
+ {
+ printf("TYPE:%d\n", cfg->arg[i]->type);
+ }
+
+ //arg_print( cfg );
+
+ if (flag_help.result != NULL)
+ {
+ printf("Help flag %d\n", flag_help.result->flag);
+ }
+
+ if (number_val.result != NULL)
+ {
+ printf("Number val :%s\n", number_val.result->ptr);
+ }
+
+ //arg_free( cfg );
+
+ return 0;
+
+exit_error:
+ arg_free( cfg );
+
+ return -1;
+ */
+
+ CmdArgFlag *enable = new CmdArgFlag();
+ CmdArgFlagConf enableConf = CmdArgFlagConf();
+ //CmdArgDefault enableDefault = CmdArgDefault((char *)"-a", &enableConf, (char *)"enable A", &enable);
+
+ CmdArgFlag enableText = CmdArgFlag();
+ CmdArgFlagConf enableTextConf = CmdArgFlagConf();
+ CmdArgDefault enableTextDefault = CmdArgDefault((char *)"-t", &enableTextConf, (char *)"enable text", &enableText);
+
+ CmdArg arguments = CmdArg();
+
+ //enableConf();
+
+}
+
+