Browse Source

+ t/t_backend_usage.c

master
Alex 'AdUser' Z 8 years ago
parent
commit
5a0fb0a3ba
  1. 2
      t/CMakeLists.txt
  2. 24
      t/t_backend_usage.c

2
t/CMakeLists.txt

@ -7,12 +7,14 @@ add_executable("t_logfile" "t_logfile.c" "${SRC_DIR}/strlcpy.c" "${SRC_DIR}
add_executable("t_matches" "t_matches.c" "${SRC_DIR}/strlcpy.c" "${SRC_DIR}/matches.c") add_executable("t_matches" "t_matches.c" "${SRC_DIR}/strlcpy.c" "${SRC_DIR}/matches.c")
add_executable("t_ipaddr" "t_ipaddr.c" "${SRC_DIR}/strlcpy.c" "${SRC_DIR}/matches.c" "${SRC_DIR}/ipaddr.c") add_executable("t_ipaddr" "t_ipaddr.c" "${SRC_DIR}/strlcpy.c" "${SRC_DIR}/matches.c" "${SRC_DIR}/ipaddr.c")
add_executable("t_config_param" "t_config_param.c" "${SRC_DIR}/strlcpy.c" "${SRC_DIR}/config.c" "${SRC_DIR}/log.c") add_executable("t_config_param" "t_config_param.c" "${SRC_DIR}/strlcpy.c" "${SRC_DIR}/config.c" "${SRC_DIR}/log.c")
add_executable("t_backend_usage" "t_backend_usage.c" "${SRC_DIR}/strlcpy.c")
add_test("tests/f2b_cmsg_*" "t_cmsg") add_test("tests/f2b_cmsg_*" "t_cmsg")
add_test("tests/f2b_logfile_*" "t_logfile") add_test("tests/f2b_logfile_*" "t_logfile")
add_test("tests/f2b_matches_*" "t_matches") add_test("tests/f2b_matches_*" "t_matches")
add_test("tests/f2b_ipaddr_*" "t_ipaddr") add_test("tests/f2b_ipaddr_*" "t_ipaddr")
add_test("tests/f2b_config_param*" "t_config_param") add_test("tests/f2b_config_param*" "t_config_param")
add_test("tests/backend/usage_*" "t_backend_usage")
add_executable("t_filter_preg" "t_filters.c" "${SRC_DIR}/filters/preg.c" "${SRC_DIR}/strlcpy.c") add_executable("t_filter_preg" "t_filters.c" "${SRC_DIR}/filters/preg.c" "${SRC_DIR}/strlcpy.c")
add_test("tests/filter/preg" "t_filter_preg") add_test("tests/filter/preg" "t_filter_preg")

24
t/t_backend_usage.c

@ -0,0 +1,24 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "../src/strlcpy.h"
#include "../src/backends/backend.h"
#include "../src/backends/shared.c"
int main() {
assert(usage_inc("test1") == 1);
assert(usage_inc("test1") == 2);
assert(usage_inc("test2") == 1);
assert(usage_inc("test1") == 3);
assert(usage_dec("test1") == 2);
assert(usage_dec("test1") == 1);
assert(usage_dec("test1") == 0);
assert(usage_dec("test1") == 0);
assert(usage_dec("test3") == 0);
return 0;
}
Loading…
Cancel
Save