From 807161b19c9da72eecc8a67d2ada69b2812784a0 Mon Sep 17 00:00:00 2001 From: Jacqueline Deans Date: Mon, 16 Jan 2023 15:54:23 -0600 Subject: [PATCH] Fix 32 bit pipeline (#1430) --- test/SIM_test_varserv/S_overrides.mk | 2 +- .../trick_utils/var_binary_parser/Makefile | 5 +-- .../var_binary_parser/test/Makefile | 4 +-- .../test/TEST_var_binary_parser.cc | 35 +++++++++++++++---- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/test/SIM_test_varserv/S_overrides.mk b/test/SIM_test_varserv/S_overrides.mk index 05507252..8910cd4f 100644 --- a/test/SIM_test_varserv/S_overrides.mk +++ b/test/SIM_test_varserv/S_overrides.mk @@ -8,7 +8,7 @@ clean: clean_test_client TEST_CLIENT_LIBS += -L${GTEST_HOME}/lib64 -L${GTEST_HOME}/lib -lgtest -lgtest_main -lpthread -L${TRICK_LIB_DIR} -ltrick_var_binary_parser test_client: models/test_client/test_client.cpp - cd models/test_client; $(TRICK_CXX) test_client.cpp -o test_client $(TRICK_CXXFLAGS) -I$(TRICK_HOME)/include $(TEST_CLIENT_LIBS) -std=c++11 + cd models/test_client; $(TRICK_CXX) test_client.cpp -o test_client $(TRICK_CXXFLAGS) $(TRICK_SYSTEM_CXXFLAGS) -I$(TRICK_HOME)/include $(TEST_CLIENT_LIBS) -std=c++11 clean_test_client: rm -f models/test_client/test_client \ No newline at end of file diff --git a/trick_source/trick_utils/var_binary_parser/Makefile b/trick_source/trick_utils/var_binary_parser/Makefile index 906a0930..b816c264 100644 --- a/trick_source/trick_utils/var_binary_parser/Makefile +++ b/trick_source/trick_utils/var_binary_parser/Makefile @@ -6,7 +6,7 @@ include ${TRICK_HOME}/share/trick/makefiles/Makefile.common #include ${TRICK_HOME}/share/trick/makefiles/Makefile.tricklib -CFLAGS = -g -Wall -Wextra -std=c++11 $(TRICK_CXXFLAGS) +CPP_FLAGS = -g -Wall -Wextra -std=c++11 $(TRICK_CXXFLAGS) $(TRICK_SYSTEM_CXXFLAGS) INCLUDE_DIRS = -I${TRICK_HOME}/include OBJDIR = obj LIBDIR = lib @@ -27,7 +27,8 @@ test: ${LIBDIR}/${LIBNAME} ${MAKE} -C test $(LIBOBJS): $(OBJDIR)/%.o : src/%.cc | $(OBJDIR) - $(CPP) $(CFLAGS) ${INCLUDE_DIRS} -c $< -o $@ + echo $(CPP_FLAGS) + $(CPP) $(CPP_FLAGS) ${INCLUDE_DIRS} -c $< -o $@ ${LIBDIR}/${LIBNAME}: ${LIBOBJS} | ${LIBDIR} ar crs $@ ${LIBOBJS} diff --git a/trick_source/trick_utils/var_binary_parser/test/Makefile b/trick_source/trick_utils/var_binary_parser/test/Makefile index 27d68d8c..8609774a 100644 --- a/trick_source/trick_utils/var_binary_parser/test/Makefile +++ b/trick_source/trick_utils/var_binary_parser/test/Makefile @@ -5,7 +5,7 @@ # # make clean - removes all files generated by make. # Flags passed to the preprocessor. -CPPFLAGS += -g -Wall -Wextra -std=c++11 ${TRICK_SYSTEM_CXXFLAGS} -I../include -I${TRICK_HOME}/include +CPPFLAGS += -g -Wall -Wextra -std=c++11 ${TRICK_SYSTEM_CXXFLAGS} -I../include -I${TRICK_HOME}/include ${CXXFLAGS} # TRICK_LIBS = ${TRICK_LIB_DIR}/libtrick_units.a EXEC_LINK_LIBS += -L${GTEST_HOME}/lib64 -L${GTEST_HOME}/lib -lgtest -lgtest_main @@ -34,4 +34,4 @@ TEST_var_binary_parser.o : TEST_var_binary_parser.cc $(OTHER_OBJECTS) TEST_var_binary_parser : TEST_var_binary_parser.o $(OTHER_OBJECTS) @echo 'Building TEST_var_binary_parser' - $(CXX) $(TRICK_SYSTEM_LDFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(LIBS) $(EXEC_LINK_LIBS) \ No newline at end of file + $(CXX) $(TRICK_SYSTEM_LDFLAGS) $(CPPFLAGS) -o $@ $^ -L${TRICK_HOME}/lib_${TRICK_HOST_CPU} $(LIBS) $(EXEC_LINK_LIBS) \ No newline at end of file diff --git a/trick_source/trick_utils/var_binary_parser/test/TEST_var_binary_parser.cc b/trick_source/trick_utils/var_binary_parser/test/TEST_var_binary_parser.cc index f81021e9..f0a3ffe8 100644 --- a/trick_source/trick_utils/var_binary_parser/test/TEST_var_binary_parser.cc +++ b/trick_source/trick_utils/var_binary_parser/test/TEST_var_binary_parser.cc @@ -795,12 +795,28 @@ TEST (BinaryParserTest, ParseUnsignedIntWrongType) { } TEST (BinaryParserTest, ParseLong) { + // Var variable; + + // // This is hard bc + // std::vector bytes = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80}; + // variable.setValue(bytes, 8, TRICK_LONG, false); + + // EXPECT_EQ(variable.getValue(), -9151314442816847873); + Var variable; - std::vector bytes = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80}; - variable.setValue(bytes, 8, TRICK_LONG, false); + // apparently this can be different by platform so we need to be careful here + size_t long_size = sizeof(long); + std::vector bytes; + for (int i = 0; i < long_size-1; i++) { + bytes.push_back(0x00); + } + bytes.push_back(0x80); + + variable.setValue(bytes, long_size, TRICK_LONG, false); + + EXPECT_EQ(variable.getValue(), LONG_MIN); - EXPECT_EQ(variable.getValue(), -9151314442816847873); } TEST (BinaryParserTest, ParseLongWrongType) { @@ -823,10 +839,17 @@ TEST (BinaryParserTest, ParseLongWrongType) { TEST (BinaryParserTest, ParseUnsignedLong) { Var variable; - std::vector bytes = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80}; - variable.setValue(bytes, 8, TRICK_UNSIGNED_LONG, false); + // apparently this can be different by platform so we need to be careful here + size_t long_size = sizeof(unsigned long); + std::vector bytes; + for (int i = 0; i < long_size-1; i++) { + bytes.push_back(0xFF); + } + bytes.push_back(0x7F); - EXPECT_EQ(variable.getValue(), 9295429630892703743); + variable.setValue(bytes, long_size, TRICK_UNSIGNED_LONG, false); + + EXPECT_EQ(variable.getValue(), LONG_MAX); } TEST (BinaryParserTest, ParseUnsignedLongWrongType) {