1 /*
2 **
3 ** reg_test.c
4 **
5 ** Copyright (C) 2014-2020 Cisco and/or its affiliates. All rights reserved.
6 **
7 ** This program is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License Version 2 as
9 ** published by the Free Software Foundation. You may not use, modify or
10 ** distribute this program under any other version of the GNU General
11 ** Public License.
12 **
13 ** This program is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ** GNU General Public License for more details.
17 **
18 ** You should have received a copy of the GNU General Public License
19 ** along with this program; if not, write to the Free Software
20 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 **
22 */
23
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
27
28 #include <stdio.h>
29 #include <stdint.h>
30 #include <ctype.h>
31 #include <stdlib.h>
32
33 #include "reg_test.h"
34 #include "sf_types.h"
35
36 #ifdef REG_TEST
37
38 uint32_t rt_ip_increment = 0;
39
getRegTestFlags(void)40 uint64_t getRegTestFlags(void)
41 {
42 static uint64_t regTestFlags = 0;
43 static bool retTestInitialized = false;
44
45 if (!retTestInitialized)
46 {
47 const char* key = getenv(REG_TEST_VARIABLE);
48
49 if (key)
50 regTestFlags = strtoul(key, NULL, 0);
51
52 retTestInitialized = true;
53 }
54
55 return regTestFlags;
56 }
getRegTestFlagsForEmail(void)57 uint64_t getRegTestFlagsForEmail(void)
58 {
59 static uint64_t regTestFlags = 0;
60 static bool retTestInitialized = false;
61
62 if (!retTestInitialized)
63 {
64 const char* key = getenv(REG_TEST_EMAIL_VARIABLE);
65
66 if (key)
67 regTestFlags = strtoul(key, NULL, 0);
68
69 retTestInitialized = true;
70 }
71
72 return regTestFlags;
73 }
74
regTestCheckIPIncrement(void)75 void regTestCheckIPIncrement(void)
76 {
77 if (REG_TEST_FLAG_INCREMENT_IP_ADDRESS & getRegTestFlags())
78 rt_ip_increment++;
79 }
80
81 #endif
82
83