From ef65503fdfbdc32624572816322179b7607b3bd4 Mon Sep 17 00:00:00 2001 From: Jessy Diamond Exum Date: Sun, 15 Oct 2017 20:41:23 -0700 Subject: [PATCH] J2534_WIN: Combined test projects into one. --- .../panda Test Native.vcxproj | 183 ------------------ .../panda Test Native.vcxproj.filters | 36 ---- drivers/windows/panda Test Native/stdafx.cpp | 8 - drivers/windows/panda Test Native/stdafx.h | 13 -- drivers/windows/panda Test Native/targetver.h | 8 - drivers/windows/panda.sln | 12 +- .../pandaJ2534DLL Test/TestHelpers.cpp | 3 +- .../windows/pandaJ2534DLL Test/TestHelpers.h | 2 +- .../pandaJ2534DLL Test.vcxproj | 2 + .../pandaJ2534DLL Test.vcxproj.filters | 3 + .../panda_tests.cpp} | 30 +-- 11 files changed, 15 insertions(+), 285 deletions(-) delete mode 100644 drivers/windows/panda Test Native/panda Test Native.vcxproj delete mode 100644 drivers/windows/panda Test Native/panda Test Native.vcxproj.filters delete mode 100644 drivers/windows/panda Test Native/stdafx.cpp delete mode 100644 drivers/windows/panda Test Native/stdafx.h delete mode 100644 drivers/windows/panda Test Native/targetver.h rename drivers/windows/{panda Test Native/pandatests.cpp => pandaJ2534DLL Test/panda_tests.cpp} (84%) diff --git a/drivers/windows/panda Test Native/panda Test Native.vcxproj b/drivers/windows/panda Test Native/panda Test Native.vcxproj deleted file mode 100644 index 9546a0f..0000000 --- a/drivers/windows/panda Test Native/panda Test Native.vcxproj +++ /dev/null @@ -1,183 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {99AEA487-44D8-4C32-BFF1-DE426DFBD32F} - Win32Proj - pandaTestNative - 8.1 - panda Test - - - - DynamicLibrary - true - v140 - Unicode - false - - - DynamicLibrary - false - v140 - true - Unicode - false - - - DynamicLibrary - true - v140 - Unicode - false - - - DynamicLibrary - false - v140 - true - Unicode - false - - - - - - - - - - - - - - - - - - - - - true - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - true - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - true - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - true - $(SolutionDir)$(Configuration)_$(PlatformShortName)\ - - - - Use - Level3 - Disabled - $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);$(SolutionDir) - WIN32;_DEBUG;%(PreprocessorDefinitions) - true - - - Windows - $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib - - - - - Use - Level3 - Disabled - $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);$(SolutionDir) - _DEBUG;%(PreprocessorDefinitions) - true - - - Windows - $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib - - - - - Level3 - Use - MaxSpeed - true - true - $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);$(SolutionDir) - WIN32;NDEBUG;%(PreprocessorDefinitions) - true - - - Windows - true - true - $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib - - - - - Level3 - Use - MaxSpeed - true - true - $(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories);$(SolutionDir) - NDEBUG;%(PreprocessorDefinitions) - true - - - Windows - true - true - $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) - kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies);$(OutDir)panda.lib - - - - - - - - - - Create - Create - Create - Create - - - - - - {5528aefb-638d-49af-b9d4-965154e7d531} - - - - - - \ No newline at end of file diff --git a/drivers/windows/panda Test Native/panda Test Native.vcxproj.filters b/drivers/windows/panda Test Native/panda Test Native.vcxproj.filters deleted file mode 100644 index ee2b9a2..0000000 --- a/drivers/windows/panda Test Native/panda Test Native.vcxproj.filters +++ /dev/null @@ -1,36 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - \ No newline at end of file diff --git a/drivers/windows/panda Test Native/stdafx.cpp b/drivers/windows/panda Test Native/stdafx.cpp deleted file mode 100644 index 16791ed..0000000 --- a/drivers/windows/panda Test Native/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// panda Test Native.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/drivers/windows/panda Test Native/stdafx.h b/drivers/windows/panda Test Native/stdafx.h deleted file mode 100644 index 43280fc..0000000 --- a/drivers/windows/panda Test Native/stdafx.h +++ /dev/null @@ -1,13 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -// Headers for CppUnitTest -#include "CppUnitTest.h" - -// TODO: reference additional headers your program requires here diff --git a/drivers/windows/panda Test Native/targetver.h b/drivers/windows/panda Test Native/targetver.h deleted file mode 100644 index 87c0086..0000000 --- a/drivers/windows/panda Test Native/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/drivers/windows/panda.sln b/drivers/windows/panda.sln index f5c99c8..a74e402 100644 --- a/drivers/windows/panda.sln +++ b/drivers/windows/panda.sln @@ -15,11 +15,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "panda_playground", "panda_p {5528AEFB-638D-49AF-B9D4-965154E7D531} = {5528AEFB-638D-49AF-B9D4-965154E7D531} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "panda Test", "panda Test Native\panda Test Native.vcxproj", "{99AEA487-44D8-4C32-BFF1-DE426DFBD32F}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "panda Driver Package", "panda Driver Package\panda Driver Package.vcxproj", "{BD34DB24-F5DC-4992-A74F-05FAF731ABED}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pandaJ2534DLL Test", "pandaJ2534DLL Test\pandaJ2534DLL Test.vcxproj", "{7912F978-B48C-4C5D-8BFD-5D1E22158E47}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tests", "pandaJ2534DLL Test\pandaJ2534DLL Test.vcxproj", "{7912F978-B48C-4C5D-8BFD-5D1E22158E47}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ECUsim DLL", "ECUsim DLL\ECUsim DLL.vcxproj", "{96E0E646-EE76-444D-9A77-A0CD7F781DEB}" EndProject @@ -55,14 +53,6 @@ Global {691DB635-C272-4B98-897E-0505B970DCA9}.Release|x64.Build.0 = Release|x64 {691DB635-C272-4B98-897E-0505B970DCA9}.Release|x86.ActiveCfg = Release|Win32 {691DB635-C272-4B98-897E-0505B970DCA9}.Release|x86.Build.0 = Release|Win32 - {99AEA487-44D8-4C32-BFF1-DE426DFBD32F}.Debug|x64.ActiveCfg = Debug|x64 - {99AEA487-44D8-4C32-BFF1-DE426DFBD32F}.Debug|x64.Build.0 = Debug|x64 - {99AEA487-44D8-4C32-BFF1-DE426DFBD32F}.Debug|x86.ActiveCfg = Debug|Win32 - {99AEA487-44D8-4C32-BFF1-DE426DFBD32F}.Debug|x86.Build.0 = Debug|Win32 - {99AEA487-44D8-4C32-BFF1-DE426DFBD32F}.Release|x64.ActiveCfg = Release|x64 - {99AEA487-44D8-4C32-BFF1-DE426DFBD32F}.Release|x64.Build.0 = Release|x64 - {99AEA487-44D8-4C32-BFF1-DE426DFBD32F}.Release|x86.ActiveCfg = Release|Win32 - {99AEA487-44D8-4C32-BFF1-DE426DFBD32F}.Release|x86.Build.0 = Release|Win32 {BD34DB24-F5DC-4992-A74F-05FAF731ABED}.Debug|x64.ActiveCfg = Debug|Win32 {BD34DB24-F5DC-4992-A74F-05FAF731ABED}.Debug|x86.ActiveCfg = Debug|Win32 {BD34DB24-F5DC-4992-A74F-05FAF731ABED}.Debug|x86.Build.0 = Debug|Win32 diff --git a/drivers/windows/pandaJ2534DLL Test/TestHelpers.cpp b/drivers/windows/pandaJ2534DLL Test/TestHelpers.cpp index 693cb7d..affea86 100644 --- a/drivers/windows/pandaJ2534DLL Test/TestHelpers.cpp +++ b/drivers/windows/pandaJ2534DLL Test/TestHelpers.cpp @@ -223,11 +223,12 @@ unsigned long J2534_set_flowctrl_filter(unsigned long chanid, unsigned long tx, return filterid; } -std::unique_ptr getPanda(unsigned long kbaud) { +std::unique_ptr getPanda(unsigned long kbaud, BOOL loopback) { auto p = panda::Panda::openPanda(""); Assert::IsTrue(p != nullptr, _T("Could not open raw panda device to test communication.")); p->set_can_speed_kbps(panda::PANDA_CAN1, kbaud); p->set_safety_mode(panda::SAFETY_ALLOUTPUT); + p->set_can_loopback(loopback); p->can_clear(panda::PANDA_CAN_RX); return p; } diff --git a/drivers/windows/pandaJ2534DLL Test/TestHelpers.h b/drivers/windows/pandaJ2534DLL Test/TestHelpers.h index 326151f..17dcee5 100644 --- a/drivers/windows/pandaJ2534DLL Test/TestHelpers.h +++ b/drivers/windows/pandaJ2534DLL Test/TestHelpers.h @@ -42,7 +42,7 @@ extern unsigned long J2534_set_BLOCK_filter(unsigned long chanid, unsigned long extern unsigned long J2534_set_flowctrl_filter(unsigned long chanid, unsigned long tx, unsigned long len, char* mask, char* pattern, char* flow, const __LineInfo* pLineInfo = NULL); -extern std::unique_ptr getPanda(unsigned long kbaud = 500); +extern std::unique_ptr getPanda(unsigned long kbaud = 500, BOOL loopback = FALSE); extern std::vector checked_panda_send(std::unique_ptr& p, uint32_t addr, bool is_29b, char* msg, uint8_t len, unsigned int num_expected=0, const __LineInfo* pLineInfo = NULL, unsigned long timeout_ms = 100); diff --git a/drivers/windows/pandaJ2534DLL Test/pandaJ2534DLL Test.vcxproj b/drivers/windows/pandaJ2534DLL Test/pandaJ2534DLL Test.vcxproj index 5e4eb98..5692382 100644 --- a/drivers/windows/pandaJ2534DLL Test/pandaJ2534DLL Test.vcxproj +++ b/drivers/windows/pandaJ2534DLL Test/pandaJ2534DLL Test.vcxproj @@ -15,6 +15,7 @@ Win32Proj pandaJ2534DLLTest 8.1 + Tests @@ -98,6 +99,7 @@ + Create Create diff --git a/drivers/windows/pandaJ2534DLL Test/pandaJ2534DLL Test.vcxproj.filters b/drivers/windows/pandaJ2534DLL Test/pandaJ2534DLL Test.vcxproj.filters index 3fc2e27..476ce45 100644 --- a/drivers/windows/pandaJ2534DLL Test/pandaJ2534DLL Test.vcxproj.filters +++ b/drivers/windows/pandaJ2534DLL Test/pandaJ2534DLL Test.vcxproj.filters @@ -56,5 +56,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/drivers/windows/panda Test Native/pandatests.cpp b/drivers/windows/pandaJ2534DLL Test/panda_tests.cpp similarity index 84% rename from drivers/windows/panda Test Native/pandatests.cpp rename to drivers/windows/pandaJ2534DLL Test/panda_tests.cpp index 17caa9a..8cacc13 100644 --- a/drivers/windows/panda Test Native/pandatests.cpp +++ b/drivers/windows/pandaJ2534DLL Test/panda_tests.cpp @@ -1,6 +1,6 @@ #include "stdafx.h" -#include "CppUnitTest.h" #include "panda/panda.h" +#include "TestHelpers.h" #include @@ -75,19 +75,13 @@ namespace pandaTestNative } }; - TEST_CLASS(CANOperations) { public: TEST_METHOD(Panda_CAN_Echo) { - auto p0 = Panda::openPanda(""); - Assert::IsFalse(p0 == nullptr, _T("Could not open panda.")); - - p0->set_safety_mode(SAFETY_ALLOUTPUT); - p0->set_can_loopback(TRUE); - p0->can_clear(PANDA_CAN_RX); + auto p0 = getPanda(500, TRUE); uint32_t addr = 0xAA; bool is_29b = FALSE; @@ -110,7 +104,7 @@ namespace pandaTestNative Assert::IsTrue(msg.bus == canbus, _T("Wrong bus.")); Assert::IsTrue(msg.len == len, _T("Wrong len.")); Assert::AreEqual(memcmp(msg.dat, candata, msg.len), 0, _T("Received CAN data not equal")); - for(int i = msg.len; i < 8; i++) + for (int i = msg.len; i < 8; i++) Assert::IsTrue(msg.dat[i] == 0, _T("Received CAN data not trailed by 0s")); } @@ -121,21 +115,12 @@ namespace pandaTestNative TEST_METHOD(Panda_CAN_ClearClears) { - auto p0 = Panda::openPanda(""); - Assert::IsFalse(p0 == nullptr, _T("Could not open panda.")); - - p0->set_safety_mode(SAFETY_ALLOUTPUT); - p0->set_can_loopback(TRUE); - p0->can_clear(PANDA_CAN_RX); - - uint8_t candata[8] = {'0', '1', '2', '3', '4', '5', '6', '7'}; - p0->can_send(0xAA, FALSE, candata, 8, PANDA_CAN1); + auto p0 = getPanda(500, TRUE); + p0->can_send(0xAA, FALSE, (const uint8_t*)"\x0\x1\x2\x3\x4\x5\x6\x7", 8, panda::PANDA_CAN1); Sleep(100); - p0->can_clear(PANDA_CAN_RX); auto can_msgs = p0->can_recv(); - printf("DERP GOD %d messages\n", can_msgs.size()); Assert::IsTrue(can_msgs.size() == 0, _T("Received messages after a clear.")); } }; @@ -146,10 +131,7 @@ namespace pandaTestNative TEST_METHOD(Panda_LIN_Echo) { - auto p0 = Panda::openPanda(""); - Assert::IsFalse(p0 == nullptr, _T("Could not open panda.")); - - p0->set_safety_mode(SAFETY_ALLOUTPUT); + auto p0 = getPanda(500); for (auto lin_port : { SERIAL_LIN1, SERIAL_LIN2 }) { p0->serial_clear(lin_port);