tests/tdef: improve test output (use OSMO_T_FMT[_ARGS])

Change-Id: Ie216bcf93b96610c46c6e616835a6793772e2baa
Related: e30d22a0 "tests/tdef: also test OSMO_TDEF_US and negative T values"
This commit is contained in:
Vadim Yanitskiy 2024-01-04 06:36:09 +07:00 committed by laforge
parent 83c8c8002f
commit 19b07c3dbe
2 changed files with 16 additions and 15 deletions

View File

@ -86,14 +86,15 @@ static struct osmo_tdef tdefs_range[] = {
printf("osmo_tdef_get(%d, %s)\t= %lu\n", T, osmo_tdef_unit_name(AS_UNIT), val); \
} while (0)
void print_tdef_info(unsigned int T)
void print_tdef_info(int T)
{
const struct osmo_tdef *t = osmo_tdef_get_entry(tdefs, T);
if (!t) {
printf("T%d=NULL", T);
printf(OSMO_T_FMT "=NULL", OSMO_T_FMT_ARGS(T));
return;
}
printf("T%d=%lu%s", T, t->val, osmo_tdef_unit_name(t->unit));
printf(OSMO_T_FMT "=%lu%s",
OSMO_T_FMT_ARGS(T), t->val, osmo_tdef_unit_name(t->unit));
if (t->val != t->default_val)
printf("(def=%lu)", t->default_val);
printf("\n");
@ -109,7 +110,7 @@ static void test_tdef_get(bool test_range)
osmo_tdefs_reset(tdefs); // make all values the default
for (i = 0; i < ARRAY_SIZE(tdefs)-1; i++) {
unsigned int T = tdefs[i].T;
int T = tdefs[i].T;
print_tdef_info(T);
for (as_unit = OSMO_TDEF_S; as_unit <= OSMO_TDEF_US; as_unit++) {
print_tdef_get_short(tdefs, T, as_unit);
@ -120,7 +121,7 @@ static void test_tdef_get(bool test_range)
return;
for (i = 0; i < ARRAY_SIZE(tdefs_range)-1; i++) {
unsigned int T = tdefs_range[i].T;
int T = tdefs_range[i].T;
print_tdef_info(T);
for (as_unit = OSMO_TDEF_S; as_unit <= OSMO_TDEF_US; as_unit++) {
print_tdef_get_short(tdefs_range, T, as_unit);
@ -347,9 +348,9 @@ static void print_fsm_state(struct osmo_fsm_inst *fi)
osmo_fsm_state_name(&test_tdef_fsm, NEXT_STATE), rc); \
} else { \
struct osmo_tdef *t = osmo_tdef_get_entry(tdefs, st->T); \
printf(" --> %s (configured as T%d%s %lu %s) rc=%d;\t", \
printf(" --> %s (configured as " OSMO_T_FMT "%s %lu %s) rc=%d;\t", \
osmo_fsm_state_name(&test_tdef_fsm, NEXT_STATE), \
st->T, st->keep_timer ? "(keep_timer)" : "", \
OSMO_T_FMT_ARGS(st->T), st->keep_timer ? " (keep_timer)" : "", \
t? t->val : 0, t? osmo_tdef_unit_name(t->unit) : "-", \
rc); \
} \

View File

@ -24,13 +24,13 @@ osmo_tdef_get(4, ms) = 100
osmo_tdef_get(4, m) = 100
osmo_tdef_get(4, custom-unit) = 100
osmo_tdef_get(4, us) = 100
T-5=100ms
X5=100ms
osmo_tdef_get(-5, s) = 1
osmo_tdef_get(-5, ms) = 100
osmo_tdef_get(-5, m) = 1
osmo_tdef_get(-5, custom-unit) = 100
osmo_tdef_get(-5, us) = 100000
T-6=100us
X6=100us
osmo_tdef_get(-6, s) = 1
osmo_tdef_get(-6, ms) = 1
osmo_tdef_get(-6, m) = 1
@ -168,8 +168,8 @@ state=A T=0, no timeout
--> B (configured as T2 100 ms) rc=0; state=B T=2, 0.100000 s remaining
--> C (configured as T3 50 m) rc=0; state=C T=3, 3000.000000 s remaining
--> D (configured as T4 100 custom-unit) rc=0; state=D T=4, 100.000000 s remaining
--> E (configured as T-5 100 ms) rc=0; state=E T=-5, 0.100000 s remaining
--> F (configured as T-6 100 us) rc=0; state=F T=-6, 0.001000 s remaining
--> E (configured as X5 100 ms) rc=0; state=E T=-5, 0.100000 s remaining
--> F (configured as X6 100 us) rc=0; state=F T=-6, 0.001000 s remaining
--> G (configured as T7 50 s) rc=0; state=G T=7, 50.000000 s remaining
--> H (configured as T8 300 s) rc=0; state=H T=8, 300.000000 s remaining
--> I (configured as T9 5 m) rc=0; state=I T=9, 300.000000 s remaining
@ -177,17 +177,17 @@ state=A T=0, no timeout
- test keep_timer:
Time passes: 123.045678 s
state=J T=10, 1076.954322 s remaining
--> K (configured as T0(keep_timer) 1 custom-unit) rc=0; state=K T=10, 1076.954322 s remaining
--> K (configured as T0 (keep_timer) 1 custom-unit) rc=0; state=K T=10, 1076.954322 s remaining
--> A (configured as T1 100 s) rc=0; state=A T=1, 100.000000 s remaining
Time passes: 23.045678 s
state=A T=1, 76.954322 s remaining
--> K (configured as T0(keep_timer) 1 custom-unit) rc=0; state=K T=1, 76.954322 s remaining
--> K (configured as T0 (keep_timer) 1 custom-unit) rc=0; state=K T=1, 76.954322 s remaining
--> A (configured as T1 100 s) rc=0; state=A T=1, 100.000000 s remaining
Time passes: 23.045678 s
state=A T=1, 76.954322 s remaining
--> L (configured as T123(keep_timer) 1 s) rc=0; state=L T=1, 76.954322 s remaining
--> L (configured as T123 (keep_timer) 1 s) rc=0; state=L T=1, 76.954322 s remaining
--> O (no timer configured for this state) rc=0; state=O T=0, no timeout
--> L (configured as T123(keep_timer) 1 s) rc=0; state=L T=123, 1.000000 s remaining
--> L (configured as T123 (keep_timer) 1 s) rc=0; state=L T=123, 1.000000 s remaining
- test T=0:
--> O (no timer configured for this state) rc=0; state=O T=0, no timeout
- test no timer: