xref: /freebsd/contrib/ntp/sntp/tests/sntptest.h (revision 98e0ffaefb0f241cda3a72395d3be04192ae0d47)
1 #ifndef SNTPTEST_H
2 #define SNTPTEST_H
3 
4 #include "tests_main.h"
5 
6 extern "C" {
7 #include "ntp_stdlib.h"
8 #include "sntp-opts.h"
9 };
10 
11 class sntptest : public ntptest {
12 protected:
13 	sntptest() {
14 		optionSaveState(&sntpOptions);
15 	}
16 
17 	~sntptest() {
18 		optionRestore(&sntpOptions);
19 	}
20 
21 	void ActivateOption(const char* option, const char* argument) {
22 		const int ARGV_SIZE = 4;
23 
24 		char* opts[ARGV_SIZE];
25 
26 		opts[0] = estrdup("sntpopts");
27 		opts[1] = estrdup(option);
28 		opts[2] = estrdup(argument);
29 		opts[3] = estrdup("127.0.0.1");
30 
31 		optionProcess(&sntpOptions, ARGV_SIZE, opts);
32 	}
33 };
34 
35 #endif // SNTPTEST_H
36