]> granicus.if.org Git - strace/blob - tests/init_delete_module.h
tests: change the license to GPL-2.0-or-later
[strace] / tests / init_delete_module.h
1 /*
2  * Helper header containing common code for finit_module, init_module,
3  * and delete_module tests.
4  *
5  * Copyright (c) 2016 Eugene Syromyatnikov <evgsyr@gmail.com>
6  * Copyright (c) 2016-2017 The strace developers.
7  * All rights reserved.
8  *
9  * SPDX-License-Identifier: GPL-2.0-or-later
10  */
11
12 #ifndef STRACE_TESTS_INIT_DELETE_MODULE_H
13 #define STRACE_TESTS_INIT_DELETE_MODULE_H
14
15 # include <stdbool.h>
16 # include <stdio.h>
17
18 enum {
19         PARAM1_LEN = 33,
20         PARAM2_LEN = 8,
21         PARAM1_BASE = 0x30,
22         PARAM2_BASE = 0x80,
23         MAX_STRLEN = 32,
24 };
25
26 static void
27 print_str(unsigned int base, unsigned int len, bool escape)
28 {
29         unsigned int i;
30
31         if (!escape) {
32                 for (i = base; i < (base + len); i++)
33                         putc(i, stdout);
34
35                 return;
36         }
37
38         for (i = base; i < (base + len); i++)
39                 printf("\\%u%u%u", (i >> 6) & 0x3, (i >> 3) & 0x7, i & 0x7);
40 }
41
42 #endif /* !STRACE_TESTS_INIT_DELETE_MODULE_H */