aboutsummaryrefslogtreecommitdiff
path: root/tests/test_malloc_free_secure.c
diff options
context:
space:
mode:
authoraxtloss <axtlos@getcryst.al>2024-09-27 12:11:52 +0200
committeraxtloss <axtlos@getcryst.al>2024-09-27 12:11:52 +0200
commit7aa261f8d57cb53cc334f6bf1920a6f8517ff054 (patch)
treef23a96feda17de737c71b45dc94e7e044410ad35 /tests/test_malloc_free_secure.c
parent27bb394bc0bf2ca66d06931bf1e73a3e20d5741a (diff)
downloadextlib-7aa261f8d57cb53cc334f6bf1920a6f8517ff054.tar.gz
extlib-7aa261f8d57cb53cc334f6bf1920a6f8517ff054.tar.bz2
Rework test suite to be more modular
Diffstat (limited to 'tests/test_malloc_free_secure.c')
-rw-r--r--tests/test_malloc_free_secure.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_malloc_free_secure.c b/tests/test_malloc_free_secure.c
new file mode 100644
index 0000000..0339cea
--- /dev/null
+++ b/tests/test_malloc_free_secure.c
@@ -0,0 +1,29 @@
+#include <string.h>
+#define USE_SECURE_MEM
+#include "../src/extlib.h"
+#undef free
+
+int
+test_malloc_free_secure ()
+{
+ size_t size = 12;
+ char *mall_test = malloc_secure (size);
+ if (!mall_test)
+ return 1;
+ if (memvcmp (mall_test, 0, size) != 0)
+ return 2;
+ free_secure ((void **) &mall_test, size);
+ if (mall_test)
+ return 3;
+ return 0;
+}
+
+struct test_t*
+test_malloc_free_secure_t ()
+{
+ struct test_t* test = malloc (sizeof (struct test_t));
+ test->test_func=test_malloc_free_secure;
+ test->test_name="test_malloc_free_secure";
+ test->test_desc="malloc_secure free_secure";
+ return test;
+}