Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/systemd-sonic-generator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ CC=gcc
CFLAGS += -std=gnu99 -D_GNU_SOURCE

CXX=g++
CXXFLAGS += -std=c++11 -D_GNU_SOURCE
LDFLAGS += -lpthread -lboost_filesystem -lboost_system -lgtest -ljson-c
CXXFLAGS += -std=c++11 -D_GNU_SOURCE -I ./
LDFLAGS += -l stdc++ -lpthread -lboost_filesystem -lboost_system -lgtest -ljson-c

BINARY = systemd-sonic-generator

$(BINARY): systemd-sonic-generator.c
$(BINARY): systemd-sonic-generator.cpp
rm -f ./systemd-sonic-generator

$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)

install: $(BINARY)
mkdir -p $(DESTDIR)
Expand All @@ -24,10 +24,12 @@ test: ssg_test
./ssg_test

ssg_test: ssg-test.cc systemd-sonic-generator.o
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
$(CXX) $(CXXFLAGS) -ggdb -o $@ $^ $(LDFLAGS)

systemd-sonic-generator.o: systemd-sonic-generator.cpp
$(CXX) $(CXXFLAGS) -ggdb -D_SSG_UNITTEST -o $@ -c $^

systemd-sonic-generator.o: systemd-sonic-generator.c
$(CC) $(CFLAGS) -D_SSG_UNITTEST -o $@ -c $^
all: $(BINARY) test

clean:
rm -f ./systemd-sonic-generator
Expand Down
11 changes: 4 additions & 7 deletions src/systemd-sonic-generator/ssg-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ class SsgMainTest : public SsgFunctionTest {

/* Find a string in a file */
bool find_string_in_file(std::string str,
std::string file_name,
int num_asics) {
std::string file_name) {
bool found = false;
std::string line;

Expand Down Expand Up @@ -243,7 +242,7 @@ class SsgMainTest : public SsgFunctionTest {
/* Run once for single instance */
finished = true;
}
EXPECT_EQ(find_string_in_file(str_t, target, num_asics),
EXPECT_EQ(find_string_in_file(str_t, target),
expected_result)
<< "Error validating " + str_t + " in " + target;
}
Expand Down Expand Up @@ -600,9 +599,8 @@ TEST_F(SsgFunctionTest, insert_instance_number) {
char input[] = "test@.service";
for (int i = 0; i <= 100; ++i) {
std::string out = "test@" + std::to_string(i) + ".service";
char* ret = insert_instance_number(input, i, "");
ASSERT_NE(ret, nullptr);
EXPECT_STREQ(ret, out.c_str());
std::string ret = insert_instance_number(input, i, "");
EXPECT_EQ(ret, out);
}
}

Expand Down Expand Up @@ -670,7 +668,6 @@ TEST_F(SsgFunctionTest, get_unit_files) {

/* TEST ssg_main() argv error */
TEST_F(SsgMainTest, ssg_main_argv) {
FILE* fp;
std::vector<char*> argv_;
std::vector<std::string> arguments = {
"ssg_main",
Expand Down
Loading