Skip to content

Commit

Permalink
Updated tests for compatibility with Alpine
Browse files Browse the repository at this point in the history
  • Loading branch information
maxberger authored and r00t- committed Jan 19, 2023
1 parent 515485f commit 929a8d6
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
14 changes: 7 additions & 7 deletions tests/MeterD0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ TEST(MeterD0, basic_dump_fd) {

std::string dumpName("/tmp/dumpD0UnitTestxyz1234");
char tempfilename[L_tmpnam + 1];
ASSERT_NE(tmpnam_r(tempfilename), (char *)0);
ASSERT_NE(tmpnam(tempfilename), (char *)0);
ASSERT_NE(strlen(tempfilename), 0ul);
std::list<Option> options;
options.push_back(Option("device", tempfilename));
Expand Down Expand Up @@ -67,7 +67,7 @@ TEST(MeterD0, basic_dump_fd_autoack) {

std::string dumpName("/tmp/dumpD0UnitTestxyz1234");
char tempfilename[L_tmpnam + 1];
ASSERT_NE(tmpnam_r(tempfilename), (char *)0);
ASSERT_NE(tmpnam(tempfilename), (char *)0);
std::list<Option> options;
options.push_back(Option("device", tempfilename));
options.push_back(Option("dump_file", (char *)dumpName.c_str()));
Expand Down Expand Up @@ -101,7 +101,7 @@ TEST(MeterD0, basic_dump_fd_autoack) {

TEST(MeterD0, HagerEHZ_basic) {
char tempfilename[L_tmpnam + 1];
ASSERT_NE(tmpnam_r(tempfilename), (char *)0);
ASSERT_NE(tmpnam(tempfilename), (char *)0);
std::list<Option> options;
options.push_back(Option("device", tempfilename));
MeterD0 m(options);
Expand Down Expand Up @@ -156,7 +156,7 @@ TEST(MeterD0, HagerEHZ_basic) {
TEST(MeterD0, HagerEHZ_waitsync) {
char tempfilename[L_tmpnam + 1];
char strend[5] = "end\0";
ASSERT_NE(tmpnam_r(tempfilename), (char *)0);
ASSERT_NE(tmpnam(tempfilename), (char *)0);
std::list<Option> options;
options.push_back(Option("device", tempfilename));
options.push_back(Option("wait_sync", strend));
Expand Down Expand Up @@ -198,7 +198,7 @@ TEST(MeterD0, HagerEHZ_waitsync) {
TEST(MeterD0, LandisGyr_basic) {
char tempfilename[L_tmpnam + 1];
char str_pullseq[12] = "2f3f210d0a";
ASSERT_NE(tmpnam_r(tempfilename), (char *)0);
ASSERT_NE(tmpnam(tempfilename), (char *)0);
std::list<Option> options;
options.push_back(Option("device", tempfilename));
options.push_back(Option("pullseq", str_pullseq));
Expand Down Expand Up @@ -295,7 +295,7 @@ int writes_hex(int fd, const char *str) {
TEST(MeterD0, ACE3000_basic) {
char tempfilename[L_tmpnam + 1];
char str_pullseq[12] = "2f3f210d0a";
ASSERT_NE(tmpnam_r(tempfilename), (char *)0);
ASSERT_NE(tmpnam(tempfilename), (char *)0);
std::list<Option> options;
options.push_back(Option("device", tempfilename));
options.push_back(Option("pullseq", str_pullseq));
Expand Down Expand Up @@ -406,7 +406,7 @@ baudrate=4, identification=\@DC341TMPBF2ZAK) [Dec 23 11:59:11][d0] Sending ack

TEST(MeterD0, LuG_E350) {
char tempfilename[L_tmpnam + 1];
ASSERT_NE(tmpnam_r(tempfilename), (char *)0);
ASSERT_NE(tmpnam(tempfilename), (char *)0);
std::list<Option> options;
options.push_back(Option("device", tempfilename));
MeterD0 m(options);
Expand Down
2 changes: 1 addition & 1 deletion tests/MeterSML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ TEST(MeterSML, EMH_basic) {
using std::fabs;

char tempfilename[L_tmpnam + 1];
ASSERT_NE(tmpnam_r(tempfilename), (char *)0);
ASSERT_NE(tmpnam(tempfilename), (char *)0);
std::list<Option> options;
options.push_back(Option("device", tempfilename));
MeterSML m(options);
Expand Down
1 change: 1 addition & 0 deletions tests/mocks/mock_metermap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ TEST(mock_metermap, basic_open_close_enabled) {
o.push_back(Option("protocol", "random"));
mock_meter *mtr = new mock_meter(o);
mtr->interval(1);
testing::Mock::AllowLeak(mtr);
EXPECT_CALL(*mtr, isEnabled()).Times(AtLeast(1)).WillRepeatedly(Return(true));
{
InSequence d;
Expand Down
10 changes: 5 additions & 5 deletions tests/ut_MeterExec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// will avoid multiple includes of the same file in a different test case
// (or linking against the real file from the CMakeLists.txt)

//#include "../src/protocols/MeterExec.cpp"
// #include "../src/protocols/MeterExec.cpp"

int writes(int fd, const char *str);

TEST(MeterExec, basic) {
char tempfilename[L_tmpnam + 1];
ASSERT_NE(tmpnam_r(tempfilename), (char *)0);
ASSERT_NE(tmpnam(tempfilename), (char *)0);
std::list<Option> options;
options.push_back(Option("command", tempfilename));

Expand All @@ -31,7 +31,7 @@ TEST(MeterExec, basic) {

TEST(MeterExec, format1) {
char tempfilename[L_tmpnam + 1];
ASSERT_NE(tmpnam_r(tempfilename), (char *)0);
ASSERT_NE(tmpnam(tempfilename), (char *)0);
std::list<Option> options;
options.push_back(Option("command", tempfilename));
options.push_back(Option("format", (char *)"$v"));
Expand All @@ -43,7 +43,7 @@ TEST(MeterExec, format1) {

TEST(MeterExec, format2) {
char tempfilename[L_tmpnam + 1];
ASSERT_NE(tmpnam_r(tempfilename), (char *)0);
ASSERT_NE(tmpnam(tempfilename), (char *)0);
std::list<Option> options;
options.push_back(Option("command", tempfilename));
options.push_back(Option("format", (char *)"$i : $v"));
Expand All @@ -55,7 +55,7 @@ TEST(MeterExec, format2) {

TEST(MeterExec, format3) {
char tempfilename[L_tmpnam + 1];
ASSERT_NE(tmpnam_r(tempfilename), (char *)0);
ASSERT_NE(tmpnam(tempfilename), (char *)0);
std::list<Option> options;
options.push_back(Option("command", tempfilename));
options.push_back(Option("format", (char *)"$t;$i : $v"));
Expand Down
10 changes: 5 additions & 5 deletions tests/ut_MeterFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// will avoid multiple includes of the same file in a different test case
// (or linking against the real file from the CMakeLists.txt)

//#include "../src/protocols/MeterFile.cpp"
// #include "../src/protocols/MeterFile.cpp"

int writes(int fd, const char *str);

TEST(MeterFile, basic) {
char tempfilename[L_tmpnam + 1];
ASSERT_NE(tmpnam_r(tempfilename), (char *)0);
ASSERT_NE(tmpnam(tempfilename), (char *)0);
std::list<Option> options;
options.push_back(Option("path", tempfilename));
options.push_back(Option("interval", 1));
Expand Down Expand Up @@ -66,7 +66,7 @@ TEST(MeterFile, basic) {

TEST(MeterFile, format1) {
char tempfilename[L_tmpnam + 1];
ASSERT_NE(tmpnam_r(tempfilename), (char *)0);
ASSERT_NE(tmpnam(tempfilename), (char *)0);
std::list<Option> options;
options.push_back(Option("path", tempfilename));
options.push_back(Option("format", (char *)"$v"));
Expand Down Expand Up @@ -112,7 +112,7 @@ TEST(MeterFile, format1) {

TEST(MeterFile, format2) {
char tempfilename[L_tmpnam + 1];
ASSERT_NE(tmpnam_r(tempfilename), (char *)0);
ASSERT_NE(tmpnam(tempfilename), (char *)0);
std::list<Option> options;
options.push_back(Option("path", tempfilename));
options.push_back(Option("format", (char *)"$i : $v"));
Expand Down Expand Up @@ -173,7 +173,7 @@ TEST(MeterFile, reading_times) {

TEST(MeterFile, format3) {
char tempfilename[L_tmpnam + 1];
ASSERT_NE(tmpnam_r(tempfilename), (char *)0);
ASSERT_NE(tmpnam(tempfilename), (char *)0);
std::list<Option> options;
options.push_back(Option("path", tempfilename));
options.push_back(Option("format", (char *)"$t;$i : $v"));
Expand Down

0 comments on commit 929a8d6

Please sign in to comment.