diff options
author | Harald Welte <laforge@gnumonks.org> | 2017-10-29 10:39:32 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2017-10-29 11:02:34 +0100 |
commit | ac0490ad2a086a4e2664bed19bfe2787cbf4d450 (patch) | |
tree | b53d2c8d120e0ad6134ac7deb25bb67c4fe2ce7c /tests | |
parent | 4c9ec22546264454662895123ff2b1310b1081ad (diff) |
tests: Don't use private version of log_info but global gprs_log_info
There's no need for each test case to carry their own log_info and
filter function. They can simply use the global gprs_log_info and
configure the stderr log verbosity according to their needs.
Change-Id: I8706a624e5d06e062d1198711aa197fbd0860769
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/bitcomp/BitcompTest.cpp | 29 | ||||
-rw-r--r-- | tests/edge/EdgeTest.cpp | 30 | ||||
-rw-r--r-- | tests/llc/LlcTest.cpp | 21 | ||||
-rw-r--r-- | tests/ms/MsTest.cpp | 21 | ||||
-rw-r--r-- | tests/tbf/TbfTest.cpp | 32 |
6 files changed, 15 insertions, 119 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 79c3ef6e..04136f5f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -28,6 +28,7 @@ tbf_TbfTest_LDADD = \ bitcomp_BitcompTest_SOURCES = bitcomp/BitcompTest.cpp ../src/egprs_rlc_compression.cpp bitcomp_BitcompTest_LDADD = \ + $(top_builddir)/src/libgprs.la \ $(LIBOSMOCORE_LIBS) \ $(COMMON_LA) diff --git a/tests/bitcomp/BitcompTest.cpp b/tests/bitcomp/BitcompTest.cpp index 4ec6f295..8dd4534e 100644 --- a/tests/bitcomp/BitcompTest.cpp +++ b/tests/bitcomp/BitcompTest.cpp @@ -113,26 +113,6 @@ struct test_data { } }; -static const struct log_info_cat default_categories[] = { - {"DCSN1", "\033[1;31m", "Concrete Syntax Notation One (CSN1)", LOGL_INFO, 0}, - {"DL1IF", "\033[1;32m", "GPRS PCU L1 interface (L1IF)", LOGL_DEBUG, 1}, - {"DRLCMAC", "\033[0;33m", "GPRS RLC/MAC layer (RLCMAC)", LOGL_DEBUG, 1}, - {"DRLCMACDATA", "\033[0;33m", "GPRS RLC/MAC layer Data (RLCMAC)", LOGL_DEBUG, 1}, - {"DRLCMACDL", "\033[1;33m", "GPRS RLC/MAC layer Downlink (RLCMAC)", LOGL_DEBUG, 1}, - {"DRLCMACUL", "\033[1;36m", "GPRS RLC/MAC layer Uplink (RLCMAC)", LOGL_DEBUG, 1}, - {"DRLCMACSCHED", "\033[0;36m", "GPRS RLC/MAC layer Scheduling (RLCMAC)", LOGL_DEBUG, 1}, - {"DRLCMACMEAS", "\033[1;31m", "GPRS RLC/MAC layer Measurements (RLCMAC)", LOGL_INFO, 1}, - {"DNS", "\033[1;34m", "GPRS Network Service Protocol (NS)", LOGL_INFO, 1}, - {"DBSSGP", "\033[1;34m", "GPRS BSS Gateway Protocol (BSSGP)", LOGL_INFO, 1}, - {"DPCU", "\033[1;35m", "GPRS Packet Control Unit (PCU)", LOGL_NOTICE, 1}, -}; - -static int filter_fn(const struct log_context *ctx, - struct log_target *tar) -{ - return 1; -} - bool result_matches(const bitvec &bits, const uint8_t *exp_data, unsigned int exp_len) { if (bits.cur_bit != exp_len) @@ -206,17 +186,12 @@ static void test_EPDAN_decode_tree(void) printf("=== end %s ===\n", __func__); } -const struct log_info debug_log_info = { - filter_fn, - (struct log_info_cat *)default_categories, - ARRAY_SIZE(default_categories), -}; - int main(int argc, char **argv) { - osmo_init_logging(&debug_log_info); + osmo_init_logging(&gprs_log_info); log_set_use_color(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); + log_parse_category_mask(osmo_stderr_target, "DRLCMACUL,1"); tall_pcu_ctx = talloc_named_const(NULL, 1, "moiji-mobile bitcompTest context"); if (!tall_pcu_ctx) diff --git a/tests/edge/EdgeTest.cpp b/tests/edge/EdgeTest.cpp index 73aed377..1abdcfd1 100644 --- a/tests/edge/EdgeTest.cpp +++ b/tests/edge/EdgeTest.cpp @@ -1154,32 +1154,6 @@ static void test_rlc_info_init() printf("=== end %s ===\n", __func__); } -static const struct log_info_cat default_categories[] = { - {"DCSN1", "\033[1;31m", "Concrete Syntax Notation One (CSN1)", LOGL_INFO, 0}, - {"DL1IF", "\033[1;32m", "GPRS PCU L1 interface (L1IF)", LOGL_DEBUG, 1}, - {"DRLCMAC", "\033[0;33m", "GPRS RLC/MAC layer (RLCMAC)", LOGL_DEBUG, 1}, - {"DRLCMACDATA", "\033[0;33m", "GPRS RLC/MAC layer Data (RLCMAC)", LOGL_DEBUG, 1}, - {"DRLCMACDL", "\033[1;33m", "GPRS RLC/MAC layer Downlink (RLCMAC)", LOGL_DEBUG, 1}, - {"DRLCMACUL", "\033[1;36m", "GPRS RLC/MAC layer Uplink (RLCMAC)", LOGL_DEBUG, 1}, - {"DRLCMACSCHED", "\033[0;36m", "GPRS RLC/MAC layer Scheduling (RLCMAC)", LOGL_DEBUG, 1}, - {"DRLCMACMEAS", "\033[1;31m", "GPRS RLC/MAC layer Measurements (RLCMAC)", LOGL_INFO, 1}, - {"DNS","\033[1;34m", "GPRS Network Service Protocol (NS)", LOGL_INFO , 1}, - {"DBSSGP","\033[1;34m", "GPRS BSS Gateway Protocol (BSSGP)", LOGL_INFO , 1}, - {"DPCU", "\033[1;35m", "GPRS Packet Control Unit (PCU)", LOGL_NOTICE, 1}, -}; - -static int filter_fn(const struct log_context *ctx, - struct log_target *tar) -{ - return 1; -} - -const struct log_info debug_log_info = { - filter_fn, - (struct log_info_cat*)default_categories, - ARRAY_SIZE(default_categories), -}; - static void setup_bts(BTS *the_bts, uint8_t ts_no, uint8_t cs = 1) { gprs_rlcmac_bts *bts; @@ -1425,12 +1399,12 @@ int main(int argc, char **argv) abort(); msgb_talloc_ctx_init(tall_pcu_ctx, 0); - osmo_init_logging(&debug_log_info); + osmo_init_logging(&gprs_log_info); log_set_use_color(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); vty_init(&pcu_vty_info); - pcu_vty_init(&debug_log_info); + pcu_vty_init(&gprs_log_info); test_coding_scheme(); test_rlc_info_init(); diff --git a/tests/llc/LlcTest.cpp b/tests/llc/LlcTest.cpp index 8df010e8..f827ef14 100644 --- a/tests/llc/LlcTest.cpp +++ b/tests/llc/LlcTest.cpp @@ -215,22 +215,6 @@ static void test_llc_merge() printf("=== end %s ===\n", __func__); } -static const struct log_info_cat default_categories[] = { - {"DPCU", "", "GPRS Packet Control Unit (PCU)", LOGL_INFO, 1}, -}; - -static int filter_fn(const struct log_context *ctx, - struct log_target *tar) -{ - return 1; -} - -const struct log_info debug_log_info = { - filter_fn, - (struct log_info_cat*)default_categories, - ARRAY_SIZE(default_categories), -}; - int main(int argc, char **argv) { struct vty_app_info pcu_vty_info = {0}; @@ -240,13 +224,14 @@ int main(int argc, char **argv) abort(); msgb_talloc_ctx_init(tall_pcu_ctx, 0); - osmo_init_logging(&debug_log_info); + osmo_init_logging(&gprs_log_info); log_set_use_color(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); log_set_log_level(osmo_stderr_target, LOGL_INFO); + log_parse_category_mask(osmo_stderr_target, "DPCU,3"); vty_init(&pcu_vty_info); - pcu_vty_init(&debug_log_info); + pcu_vty_init(&gprs_log_info); test_llc_queue(); test_llc_meta(); diff --git a/tests/ms/MsTest.cpp b/tests/ms/MsTest.cpp index d66f578e..ac35998a 100644 --- a/tests/ms/MsTest.cpp +++ b/tests/ms/MsTest.cpp @@ -514,22 +514,6 @@ static void test_ms_cs_selection() printf("=== end %s ===\n", __func__); } -static const struct log_info_cat default_categories[] = { - {"DPCU", "", "GPRS Packet Control Unit (PCU)", LOGL_INFO, 1}, -}; - -static int filter_fn(const struct log_context *ctx, - struct log_target *tar) -{ - return 1; -} - -const struct log_info debug_log_info = { - filter_fn, - (struct log_info_cat*)default_categories, - ARRAY_SIZE(default_categories), -}; - int main(int argc, char **argv) { struct vty_app_info pcu_vty_info = {0}; @@ -539,13 +523,14 @@ int main(int argc, char **argv) abort(); msgb_talloc_ctx_init(tall_pcu_ctx, 0); - osmo_init_logging(&debug_log_info); + osmo_init_logging(&gprs_log_info); log_set_use_color(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); log_set_log_level(osmo_stderr_target, LOGL_INFO); + log_parse_category_mask(osmo_stderr_target, "DPCU,3:DRLCMAC,3"); vty_init(&pcu_vty_info); - pcu_vty_init(&debug_log_info); + pcu_vty_init(&gprs_log_info); test_ms_state(); test_ms_callback(); diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp index 0db7fde7..195bec5f 100644 --- a/tests/tbf/TbfTest.cpp +++ b/tests/tbf/TbfTest.cpp @@ -3182,32 +3182,6 @@ static void test_tbf_egprs_dl() -static const struct log_info_cat default_categories[] = { - {"DCSN1", "\033[1;31m", "Concrete Syntax Notation One (CSN1)", LOGL_INFO, 0}, - {"DL1IF", "\033[1;32m", "GPRS PCU L1 interface (L1IF)", LOGL_DEBUG, 1}, - {"DRLCMAC", "\033[0;33m", "GPRS RLC/MAC layer (RLCMAC)", LOGL_DEBUG, 1}, - {"DRLCMACDATA", "\033[0;33m", "GPRS RLC/MAC layer Data (RLCMAC)", LOGL_DEBUG, 1}, - {"DRLCMACDL", "\033[1;33m", "GPRS RLC/MAC layer Downlink (RLCMAC)", LOGL_DEBUG, 1}, - {"DRLCMACUL", "\033[1;36m", "GPRS RLC/MAC layer Uplink (RLCMAC)", LOGL_DEBUG, 1}, - {"DRLCMACSCHED", "\033[0;36m", "GPRS RLC/MAC layer Scheduling (RLCMAC)", LOGL_DEBUG, 1}, - {"DRLCMACMEAS", "\033[1;31m", "GPRS RLC/MAC layer Measurements (RLCMAC)", LOGL_INFO, 1}, - {"DNS","\033[1;34m", "GPRS Network Service Protocol (NS)", LOGL_INFO , 1}, - {"DBSSGP","\033[1;34m", "GPRS BSS Gateway Protocol (BSSGP)", LOGL_INFO , 1}, - {"DPCU", "\033[1;35m", "GPRS Packet Control Unit (PCU)", LOGL_NOTICE, 1}, -}; - -static int filter_fn(const struct log_context *ctx, - struct log_target *tar) -{ - return 1; -} - -const struct log_info debug_log_info = { - filter_fn, - (struct log_info_cat*)default_categories, - ARRAY_SIZE(default_categories), -}; - static void test_packet_access_rej_prr_no_other_tbfs() { BTS the_bts; @@ -3348,13 +3322,15 @@ int main(int argc, char **argv) abort(); msgb_talloc_ctx_init(tall_pcu_ctx, 0); - osmo_init_logging(&debug_log_info); + osmo_init_logging(&gprs_log_info); log_set_use_color(osmo_stderr_target, 0); log_set_print_filename(osmo_stderr_target, 0); bssgp_set_log_ss(DBSSGP); + log_parse_category_mask(osmo_stderr_target, "DL1IF,1:DRLCMAC,1:DRLCMACDATA,1:DRLCMACDL,1:" + "DRLCMACUL,1:DRLCMACSCHED,1:DRLCMACMEAS,3:DNS,3:DBSSGP,3:DPCU,5"); vty_init(&pcu_vty_info); - pcu_vty_init(&debug_log_info); + pcu_vty_init(&gprs_log_info); test_tbf_base(); test_tbf_tlli_update(); |