]>
git.proxmox.com Git - mirror_frr.git/blob - tests/lib/test_assert.c
2 * Quick test for assert()
3 * Copyright (C) 2021 David Lamparter for NetDEF, Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 /* make sure this works with assert.h & nothing else. also check the include
25 * shadowing, we don't want to pick up system assert.h
29 __attribute__((noinline
))
30 static void func_for_bt(int number
)
33 assertf(number
> 3, "(A) the number was %d", number
);
38 #include "lib/thread.h"
39 #include "lib/sigevent.h"
41 int main(int argc
, char **argv
)
44 struct thread_master
*master
;
46 zlog_aux_init("NONE: ", LOG_DEBUG
);
49 number
= atoi(argv
[1]);
52 assertf(number
> 1, "(B) the number was %d", number
);
54 /* set up SIGABRT handler */
55 master
= thread_master_create("test");
56 signal_init(master
, 0, NULL
);
60 assertf(number
> 5, "(C) the number was %d", number
);
62 assertf(number
> 10, "(D) the number was %d", number
);