From d27cd1b19ee9582da1df084e8b1b35a60e5955f5 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 3 Dec 2018 17:23:55 +0100 Subject: [PATCH] Fixed unit tests, use uniqe file names --- .../codec/test/TestFreeRDPCodecProgressive.c | 10 ++- libfreerdp/crypto/test/TestKnownHosts.c | 82 ++++++++++++++-------- winpr/libwinpr/file/test/TestFileCreateFile.c | 17 +++-- 3 files changed, 74 insertions(+), 35 deletions(-) diff --git a/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c b/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c index e99c55a..8b648ee 100644 --- a/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c +++ b/libfreerdp/codec/test/TestFreeRDPCodecProgressive.c @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -923,7 +924,14 @@ static int test_progressive_ms_sample(char* ms_sample_path) int TestFreeRDPCodecProgressive(int argc, char* argv[]) { char* ms_sample_path; - ms_sample_path = GetKnownSubPath(KNOWN_PATH_TEMP, "EGFX_PROGRESSIVE_MS_SAMPLE"); + char name[8192]; + SYSTEMTIME systemTime; + GetSystemTime(&systemTime); + sprintf_s(name, sizeof(name), + "EGFX_PROGRESSIVE_MS_SAMPLE-%04"PRIu16"%02"PRIu16"%02"PRIu16"%02"PRIu16"%02"PRIu16"%02"PRIu16"%04"PRIu16, + systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour, systemTime.wMinute, + systemTime.wSecond, systemTime.wMilliseconds); + ms_sample_path = GetKnownSubPath(KNOWN_PATH_TEMP, name); if (!ms_sample_path) { diff --git a/libfreerdp/crypto/test/TestKnownHosts.c b/libfreerdp/crypto/test/TestKnownHosts.c index 2b30638..4bd3a37 100644 --- a/libfreerdp/crypto/test/TestKnownHosts.c +++ b/libfreerdp/crypto/test/TestKnownHosts.c @@ -19,34 +19,39 @@ #include #include +#include + #include static int prepare(const char* currentFileV2, const char* legacyFileV2, const char* legacyFile) { - char* legacy[] = { - "someurl ff:11:22:dd\r\n", - "otherurl aa:bb:cc:dd\r", - "legacyurl aa:bb:cc:dd\n" + char* legacy[] = + { + "someurl ff:11:22:dd\r\n", + "otherurl aa:bb:cc:dd\r", + "legacyurl aa:bb:cc:dd\n" }; - char* hosts[] = { + char* hosts[] = + { "#somecomment\r\n" "someurl 3389 ff:11:22:dd subject issuer\r\n" " \t#anothercomment\r\n" - "otherurl\t3389\taa:bb:cc:dd\tsubject2\tissuer2\r" + "otherurl\t3389\taa:bb:cc:dd\tsubject2\tissuer2\r" }; FILE* fl = NULL; FILE* fc = NULL; size_t i; - fc = fopen(currentFileV2, "w+"); + if (!fc) goto finish; fl = fopen(legacyFileV2, "w+"); + if (!fl) goto finish; - for (i=0; i #include #include +#include int TestFileCreateFile(int argc, char* argv[]) { @@ -13,9 +14,16 @@ int TestFileCreateFile(int argc, char* argv[]) DWORD written; const char buffer[] = "Some random text\r\njust want it done."; char cmp[sizeof(buffer)]; - LPSTR name = GetKnownSubPath(KNOWN_PATH_TEMP, "CreateFile.testfile"); - + char sname[8192]; + LPSTR name; int rc = 0; + SYSTEMTIME systemTime; + GetSystemTime(&systemTime); + sprintf_s(sname, sizeof(sname), + "CreateFile-%04"PRIu16"%02"PRIu16"%02"PRIu16"%02"PRIu16"%02"PRIu16"%02"PRIu16"%04"PRIu16, + systemTime.wYear, systemTime.wMonth, systemTime.wDay, systemTime.wHour, systemTime.wMinute, + systemTime.wSecond, systemTime.wMilliseconds); + name = GetKnownSubPath(KNOWN_PATH_TEMP, sname); if (!name) return -1; @@ -23,11 +31,13 @@ int TestFileCreateFile(int argc, char* argv[]) /* On windows we would need '\\' or '/' as seperator. * Single '\' do not work. */ hr = PathCchConvertStyleA(name, strlen(name), PATH_STYLE_UNIX); + if (FAILED(hr)) rc = -1; handle = CreateFileA(name, GENERIC_READ | GENERIC_WRITE, 0, NULL, - CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); + CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); + if (!handle) { free(name); @@ -77,6 +87,5 @@ int TestFileCreateFile(int argc, char* argv[]) rc = -1; free(name); - return rc; } -- 2.7.4