Browse Source

messed around with the makefile and tests to get them back running

stefan 1 year ago
parent
commit
08a9aca942

+ 1 - 1
example/main.c

@@ -234,7 +234,7 @@ int main(int argc, char **argv)
         {"remove", removeCommandPerms, sizeof(removeCommandPerms)/sizeof(removeCommandPerms[0])}
     };
 
-    shellmatta_auth_init(handle, userList, 2, permList, 2, false, NULL);
+    shellmatta_auth_init(handle, userList, 2, permList, 2, false, NULL, NULL);
 
     while(exitRequest == false)
     {

+ 10 - 8
makefile

@@ -7,6 +7,7 @@
 # 
 
 OBJ_DIR := output/
+OBJ_DIR_EXAMPLE := $(OBJ_DIR)example_obj/
 INTEGRATIONTEST_CPP_OBJ_DIR := $(OBJ_DIR)test/integrationtest/
 INTEGRATIONTEST_C_OBJ_DIR := $(INTEGRATIONTEST_CPP_OBJ_DIR)
 UNITTEST_OBJ_DIR := $(OBJ_DIR)test/unittest/
@@ -20,8 +21,7 @@ SOURCES :=  src/shellmatta.c                \
             src/shellmatta_history.c        \
             src/shellmatta_utils.c          \
             src/shellmatta_escape.c         \
-            src/shellmatta_opt.c            \
-            src/shellmatta_auth.c
+            src/shellmatta_opt.c
 
 INCLUDES    := api .
 
@@ -58,7 +58,8 @@ UNITTEST_CPPOBJ  := $(patsubst %.cpp,$(UNITTEST_OBJ_DIR)%.o,$(UNITTEST_SOURCES))
 INTEGRATIONTEST_CPPOBJ  :=  $(patsubst %.cpp,$(INTEGRATIONTEST_CPP_OBJ_DIR)%.o,$(INTEGRATIONTEST_SOURCES))
 INTEGRATIONTEST_COBJ    :=  $(patsubst %.c,$(INTEGRATIONTEST_CPP_OBJ_DIR)%.o,$(SOURCES))
 
-CFLAGS      := $(INCLUDES:%=-I%) -g -Wall -Werror -Wextra -pedantic -DSHELLMATTA_HELP_ALIAS=\(char*\)\"?\" -DSHELLMATTA_AUTHENTICATION
+CFLAGS      := $(INCLUDES:%=-I%) -g -Wall -Werror -Wextra -pedantic -DSHELLMATTA_HELP_ALIAS=\(char*\)\"?\"
+CFLAGS_EXAMPLE = $(CFLAGS) -DSHELLMATTA_AUTHENTICATION
 TESTFLAGS   := $(CFLAGS) -fprofile-arcs -ftest-coverage
 TESTLFLAGS  := -fprofile-arcs -Wl,--allow-multiple-definition
 
@@ -66,8 +67,8 @@ DEPEND      = -MT $@ -MF "$(@:%.o=%.d)" -MG -MM
 
 COBJ    := $(patsubst %.c,$(OBJ_DIR)%.o,$(SOURCES))
 
-EXAMPLE_SOURCES := example/main.c
-EXAMPLE_COBJ     := $(patsubst %.c,$(OBJ_DIR)%.o,$(EXAMPLE_SOURCES))
+EXAMPLE_SOURCES := $(SOURCES) src/shellmatta_auth.c example/main.c
+EXAMPLE_COBJ     := $(patsubst %.c,$(OBJ_DIR_EXAMPLE)%.o,$(EXAMPLE_SOURCES))
 
 EXAMPLE_TARGET  := $(OBJ_DIR)example/example
 
@@ -131,7 +132,7 @@ doc:
 clean:
 	- rm -rf $(OBJ_DIR)
 
-$(EXAMPLE_TARGET): $(COBJ) $(EXAMPLE_COBJ)
+$(EXAMPLE_TARGET): $(EXAMPLE_COBJ)
 	- @mkdir -p $(@D)
 	$(CC) $(LFLAGS) $(LIB_PATH) -o $@ $^ $(LIBS)
 
@@ -154,8 +155,9 @@ $(COBJ):
 
 $(EXAMPLE_COBJ):
 	- @mkdir -p $(@D)
-	@$(CC) -c $(CFLAGS) $(DEPEND) -o $@  $(subst $(OBJ_DIR), ,$(@:%.o=%.c))
-	$(CC) -c $(CFLAGS) -o $@  $(subst $(OBJ_DIR), ,$(@:%.o=%.c))
+	@echo sdlfkjsdlk
+	@$(CC) -c $(CFLAGS_EXAMPLE) $(DEPEND) -o $@  $(subst $(OBJ_DIR_EXAMPLE), ,$(@:%.o=%.c))
+	$(CC) -c $(CFLAGS_EXAMPLE) -o $@  $(subst $(OBJ_DIR_EXAMPLE), ,$(@:%.o=%.c))
 
 $(UNITTEST_CPPOBJ):
 	- @mkdir -p $(@D)

File diff suppressed because it is too large
+ 2282 - 1171
test/framework/catch.hpp


+ 6 - 13
test/integrationtest/test_integration.cpp

@@ -11,12 +11,12 @@
  * @brief   integration test implementation for some general functions
  * @author  Stefan Strobel <stefan.strobel@shimatta.net>
  */
-
 #include "test/framework/catch.hpp"
 extern "C" {
 #include "shellmatta.h"
 }
 #include <string.h>
+using Catch::Matchers::Equals;
 
 static uint32_t write_callCnt = 0u;
 static char write_data[1024];
@@ -65,7 +65,6 @@ TEST_CASE( "shellmatta empty function" ) {
     shellmatta_handle_t handle;
     char buffer[1024];
     char historyBuffer[1024];
-    char *dummyData =   (char*)"\r\nshellmatta->";
 
     shellmatta_doInit(  &inst,
                         &handle,
@@ -84,8 +83,7 @@ TEST_CASE( "shellmatta empty function" ) {
     shellmatta_processData(handle, (char*)"\r", 1);
 
     CHECK( write_length == 14u);
-    REQUIRE( strcmp(dummyData, write_data) == 0);
-
+    REQUIRE_THAT( write_data, Equals("\r\nshellmatta->") );
 }
 
 TEST_CASE( "shellmatta heredoc test" ) {
@@ -94,9 +92,6 @@ TEST_CASE( "shellmatta heredoc test" ) {
     shellmatta_handle_t handle;
     char buffer[1024];
     char historyBuffer[1024];
-    char *dummyData =   (char*)"do this ";
-    char *dummyStdin =  (char*)"asdf\r\n"
-                        "1234";
 
     shellmatta_doInit(  &inst,
                         &handle,
@@ -119,9 +114,9 @@ TEST_CASE( "shellmatta heredoc test" ) {
                                 , 33);
 
     CHECK( doSomethingStdinLength == 10u);
-    CHECK( strcmp(dummyStdin, doSomethingStdin) == 0);
+    CHECK_THAT( doSomethingStdin, Equals("asdf\r\n1234") );
     CHECK( doSomethingLength == 8u);
-    REQUIRE( strcmp(dummyData, doSomethingArguments) == 0);
+    REQUIRE_THAT( doSomethingArguments, Equals("do this ") );
 }
 
 TEST_CASE( "shellmatta heredoc test empty" ) {
@@ -130,7 +125,6 @@ TEST_CASE( "shellmatta heredoc test empty" ) {
     shellmatta_handle_t handle;
     char buffer[1024];
     char historyBuffer[1024];
-    char *dummyData =   (char*)"do this ";
 
     shellmatta_doInit(  &inst,
                         &handle,
@@ -153,7 +147,7 @@ TEST_CASE( "shellmatta heredoc test empty" ) {
     CHECK( doSomethingStdinLength == 0u);
     CHECK( NULL == doSomethingStdin );
     CHECK( doSomethingLength == 8u);
-    REQUIRE( strcmp(dummyData, doSomethingArguments) == 0);
+    REQUIRE_THAT( doSomethingArguments, Equals("do this ") );
 }
 
 TEST_CASE( "shellmatta remove function" ) {
@@ -185,8 +179,7 @@ TEST_CASE( "shellmatta remove function" ) {
     shellmatta_processData(handle, (char*)"?\r", 2);
 
     CHECK( write_length == strlen(dummyData));
-    CHECK( strcmp(dummyData, write_data) == 0);
-
+    CHECK_THAT( write_data, Equals(dummyData) );
 
     write_callCnt = 0u;
     memset(write_data, 0, sizeof(write_data));

+ 6 - 6
test/unittest/shellmatta_utils/test_utils_insertChars.cpp

@@ -32,7 +32,7 @@ TEST_CASE( "shellmatta_insertChars normal call" ) {
     memset(write_data, 0, sizeof(write_data));
     write_idx = 0u;
 
-    utils_insertChars(&inst, (char*)"blksdflsd kfjlk", 4u);
+    utils_insertChars(&inst, (char*)"blksdflsd kfjlk", 4u, false);
 
     CHECK( inst.cursor == 12);
     CHECK( inst.inputCount == 14);
@@ -60,7 +60,7 @@ TEST_CASE( "shellmatta_insertChars overwrite" ) {
     memset(write_data, 0, sizeof(write_data));
     write_idx = 0u;
 
-    utils_insertChars(&inst, (char*)"blksdflsd kfjlk", 4u);
+    utils_insertChars(&inst, (char*)"blksdflsd kfjlk", 4u, false);
 
     CHECK( inst.cursor == 12);
     CHECK( inst.inputCount == 12);
@@ -88,7 +88,7 @@ TEST_CASE( "shellmatta_insertChars append" ) {
     memset(write_data, 0, sizeof(write_data));
     write_idx = 0u;
 
-    utils_insertChars(&inst, (char*)"blksdflsd kfjlk", 4u);
+    utils_insertChars(&inst, (char*)"blksdflsd kfjlk", 4u, false);
 
     CHECK( inst.cursor == 14);
     CHECK( inst.inputCount == 14);
@@ -115,7 +115,7 @@ TEST_CASE( "shellmatta_insertChars 0 length" ) {
     memset(write_data, 0, sizeof(write_data));
     write_idx = 0u;
 
-    utils_insertChars(&inst, (char*)"blksdflsd kfjlk", 0u);
+    utils_insertChars(&inst, (char*)"blksdflsd kfjlk", 0u, false);
 
     CHECK( inst.cursor == 8u );
     CHECK( inst.inputCount == 10u );
@@ -142,7 +142,7 @@ TEST_CASE( "shellmatta_insertChars buffer full" ) {
     memset(write_data, 0, sizeof(write_data));
     write_idx = 0u;
 
-    utils_insertChars(&inst, (char*)"blksdflsd kfjlk", 10u);
+    utils_insertChars(&inst, (char*)"blksdflsd kfjlk", 10u, false);
 
     CHECK( inst.cursor == 18u );
     CHECK( inst.inputCount == 20u );
@@ -170,7 +170,7 @@ TEST_CASE( "shellmatta_insertChars buffer overflow by 1" ) {
     memset(write_data, 0, sizeof(write_data));
     write_idx = 0u;
 
-    utils_insertChars(&inst, (char*)"blksdflsd kfjlk", 11u);
+    utils_insertChars(&inst, (char*)"blksdflsd kfjlk", 11u, false);
 
     CHECK( inst.cursor == 18u );
     CHECK( inst.inputCount == 20u );

+ 2 - 2
test/unittest/shellmatta_utils/test_utils_writeEcho.cpp

@@ -18,7 +18,7 @@ TEST_CASE( "shellmatta_writeEcho echo enabled" ) {
 
     shellmatta_instance_t inst;
     char buffer[20];
-    char dummyData[29];
+    char dummyData[29] = {0};
 
     inst.buffer = buffer;
     inst.bufferSize = 20;
@@ -43,7 +43,7 @@ TEST_CASE( "shellmatta_writeEcho echo disabled" ) {
 
     shellmatta_instance_t inst;
     char buffer[20];
-    char dummyData[29];
+    char dummyData[29] = {0};
 
     inst.buffer = buffer;
     inst.bufferSize = 20;