]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
bench/bench_lru: make it build again, and check it in CI docs-develop-benc-tyiqon/deployments/4769
authorOto Šťáva <oto.stava@nic.cz>
Fri, 2 Aug 2024 13:43:04 +0000 (15:43 +0200)
committerOto Šťáva <oto.stava@nic.cz>
Fri, 2 Aug 2024 13:43:04 +0000 (15:43 +0200)
It's not too important, but I just stumbled upon this and it looked like
nobody has touched it in a long time. Since it's not completely broken
(the fix is trivial), I decided to fix it and add it to CI to ensure
that we can still build it. Maybe `lru` will be used some more at some
point again in the future...

.gitlab-ci.yml
bench/bench_lru.c

index cf1d77c95b719077af141e47fe5b408a0e2351a7..832a85f229b81c19522a1538e88d5328a7a92513 100644 (file)
@@ -130,7 +130,7 @@ build-arch:
 build-stable:
   <<: *build
   script:
-    - meson build_ci_stable --prefix=$PREFIX -Dmalloc=disabled -Dwerror=true -Dextra_tests=enabled
+    - meson build_ci_stable --prefix=$PREFIX -Dmalloc=disabled -Dwerror=true -Dextra_tests=enabled -Dbench=enabled
     - ninja -C build_ci_stable
     - ninja -C build_ci_stable install >/dev/null
     - ${MESON_TEST} --suite unit --suite config --suite dnstap --no-suite snowflake
index 06f77c0d9f5be9d9fb42c2b68ae7100bc3fca189..b0060773816df48ef9d5464dad4ea75fcdb75424 100644 (file)
 #include "daemon/engine.h"
 #include "lib/selection.h"
 
-typedef kr_nsrep_lru_t lru_bench_t;
+typedef lru_t(unsigned) lru_bench_t;
 
 #define p_out(...) do { \
        printf(__VA_ARGS__); \
-       fflush(stdout); \
-       } while (0)
-#define p_err(...) fprintf(stderr, __VA_ARGS__)
+       (void)fflush(stdout); \
+} while (0)
+#define p_err(...) ((void)fprintf(stderr, __VA_ARGS__))
 
 #ifndef LRU_RTT_SIZE
 #define LRU_RTT_SIZE 65536 /**< NS RTT cache size */
@@ -27,7 +27,7 @@ typedef kr_nsrep_lru_t lru_bench_t;
 
 static int die(const char *cause)
 {
-       fprintf(stderr, "%s: %s\n", cause, strerror(errno));
+       (void)fprintf(stderr, "%s: %s\n", cause, strerror(errno));
        exit(1);
 }
 
@@ -171,7 +171,7 @@ int main(int argc, char ** argv)
        struct key *keys = read_lines(argv[2], &key_count, &data_to_free);
        size_t run_count;
        {
-               size_t run_log = atoi(argv[1]);
+               size_t run_log = atoi(argv[1]); // NOLINT: atoi is fine for this tool...
                assert(run_log < 64);
                run_count = 1ULL << run_log;
                p_err("\ntest run length:\t2^");
@@ -179,7 +179,7 @@ int main(int argc, char ** argv)
        }
 
        struct timeval time;
-       const int lru_size = argc > 4 ? atoi(argv[4]) : LRU_RTT_SIZE;
+       const int lru_size = argc > 4 ? atoi(argv[4]) : LRU_RTT_SIZE; // NOLINT: ditto atoi
 
        lru_bench_t *lru;
        #ifdef lru_create