]> git.meshlink.io Git - meshlink/blobdiff - test/ephemeral.c
Refactor the non-blackbox test suite.
[meshlink] / test / ephemeral.c
index 6921b53904a68a3dd556937cd1a62043ec2ce86f..845b218299cbf13fff8e74a1bc6c923314c707a7 100644 (file)
@@ -1,26 +1,10 @@
 #include <stdio.h>
+#include <stdlib.h>
 #include <sys/time.h>
 #include <assert.h>
 
 #include "meshlink.h"
-
-void log_cb(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) {
-       static struct timeval tv0;
-       struct timeval tv;
-
-       if(tv0.tv_sec == 0) {
-               gettimeofday(&tv0, NULL);
-       }
-
-       gettimeofday(&tv, NULL);
-       fprintf(stderr, "%u.%.03u ", (unsigned int)(tv.tv_sec - tv0.tv_sec), (unsigned int)tv.tv_usec / 1000);
-
-       if(mesh) {
-               fprintf(stderr, "(%s) ", mesh->name);
-       }
-
-       fprintf(stderr, "[%d] %s\n", level, text);
-}
+#include "utils.h"
 
 int main() {
        meshlink_set_log_cb(NULL, MESHLINK_DEBUG, log_cb);
@@ -78,6 +62,4 @@ int main() {
 
        meshlink_close(mesh1);
        meshlink_close(mesh2);
-
-       return 0;
 }