-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- allow whitespace in ALLOW_USERS and ALLOW_GROUPS
- Loading branch information
Showing
11 changed files
with
193 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.o | ||
sysconfig-get1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# | ||
# Makefile.am for snapper/testsuite | ||
# | ||
|
||
CXXFLAGS += -std=gnu++0x | ||
|
||
INCLUDES = -I$(top_srcdir) | ||
|
||
LDADD = ../snapper/libsnapper.la | ||
|
||
noinst_SCRIPTS = run-all | ||
|
||
noinst_PROGRAMS = sysconfig-get1 | ||
|
||
sysconfig_get1_SOURCES = sysconfig-get1.cc common.h | ||
|
||
EXTRA_DIST = $(noinst_SCRIPTS) sysconfig-get1.txt | ||
|
||
check: | ||
./run-all | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
#include <string> | ||
|
||
using namespace std; | ||
|
||
|
||
template <typename Type> void | ||
check_failure(const char* str, Type actual, Type expected, const char* file, | ||
int line, const char* func) | ||
{ | ||
std::cerr << file << ":" << line << ": \"" << func << "\"" << std::endl; | ||
std::cerr << "check \"" << str << "\"" << " failed. expected " << expected | ||
<< ", actual " << actual << "." << std::endl; | ||
|
||
exit(EXIT_FAILURE); | ||
} | ||
|
||
|
||
#define check_true(expr) \ | ||
do { \ | ||
bool actual = (expr); \ | ||
if (!actual) \ | ||
check_failure(#expr, actual, true, __FILE__, __LINE__, \ | ||
__PRETTY_FUNCTION__); \ | ||
} while (0) | ||
|
||
|
||
#define check_zero(expr) \ | ||
do { \ | ||
int actual = (expr); \ | ||
if (actual != 0) \ | ||
check_failure(#expr, actual, 0, __FILE__, __LINE__, \ | ||
__PRETTY_FUNCTION__); \ | ||
} while (0) | ||
|
||
|
||
#define check_equal(expr, expected) \ | ||
do { \ | ||
typeof (expected) actual = (expr); \ | ||
if (actual != expected) \ | ||
check_failure(#expr, actual, expected, __FILE__, __LINE__, \ | ||
__PRETTY_FUNCTION__); \ | ||
} while (0) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
|
||
function run() | ||
{ | ||
cmd=$1 | ||
|
||
echo | ||
echo "*** running $cmd ***" | ||
echo | ||
|
||
./$cmd | ||
|
||
if [ $? != 0 ] ; then | ||
echo "failed" | ||
exit 1 | ||
fi | ||
} | ||
|
||
|
||
run sysconfig-get1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
#include <stdlib.h> | ||
#include <iostream> | ||
#include <boost/algorithm/string.hpp> | ||
|
||
#include "common.h" | ||
|
||
#include <snapper/AsciiFile.h> | ||
|
||
using namespace snapper; | ||
|
||
|
||
int | ||
main() | ||
{ | ||
SysconfigFile s("sysconfig-get1.txt"); | ||
|
||
string tmp_string; | ||
|
||
check_true(s.getValue("S1", tmp_string)); | ||
check_equal(tmp_string, string("hello")); | ||
|
||
bool tmp_bool; | ||
|
||
check_true(s.getValue("B1", tmp_bool)); | ||
check_equal(tmp_bool, true); | ||
|
||
check_true(s.getValue("B2", tmp_bool)); | ||
check_equal(tmp_bool, false); | ||
|
||
vector<string> tmp_vector; | ||
|
||
check_true(s.getValue("V1", tmp_vector)); | ||
check_equal(boost::join(tmp_vector, "-"), string("one word")); | ||
|
||
check_true(s.getValue("V2", tmp_vector)); | ||
check_equal(boost::join(tmp_vector, "-"), string("two-words")); | ||
|
||
check_true(s.getValue("V3", tmp_vector)); | ||
check_equal(boost::join(tmp_vector, "-"), string("now-three-words")); | ||
|
||
check_true(s.getValue("V4", tmp_vector)); | ||
check_equal(boost::join(tmp_vector, "-"), string("c:\\io.sys")); | ||
|
||
check_true(!s.getValue("V5", tmp_vector)); | ||
|
||
exit(EXIT_SUCCESS); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
S1="hello" | ||
|
||
B1="yes" | ||
B2="no" | ||
|
||
V1="one\ word" | ||
V2="two words" | ||
V3=" now three words " | ||
V4="c:\\io.sys" | ||
V5="error\" | ||
|