-
Notifications
You must be signed in to change notification settings - Fork 55
/
OacrTests.cpp
40 lines (35 loc) · 1.38 KB
/
OacrTests.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//
#ifdef _WIN32
#include "common/Common.hpp"
using namespace testing;
TEST(OacrTests, BuildMachineOnly_VerifyOacrOutputFolderExists)
{
char *buildNumber;
// The BUILD_BUILDID variable should only exist on a build machine
if (0 == _dupenv_s(&buildNumber, nullptr, "BUILD_BUILDID") && (buildNumber != nullptr))
{
LPCSTR outputFolder = "F:\\OACR\\Output"; // Output folder that must exist
DWORD attributes = GetFileAttributesA(outputFolder);
bool oacrOutputFolderExists = (attributes != INVALID_FILE_ATTRIBUTES) && ((attributes & FILE_ATTRIBUTE_DIRECTORY) != 0);
ASSERT_TRUE(oacrOutputFolderExists);
free(buildNumber);
}
}
TEST(OacrTests, BuildMachineOnly_VerifyThisBuildHasNoOacrErrors)
{
char *buildNumber;
// The BUILD_BUILDID variable should only exist on a build machine
if (0 == _dupenv_s(&buildNumber, nullptr, "BUILD_BUILDID") && (buildNumber != nullptr))
{
char pathToFile[MAX_PATH];
snprintf(pathToFile, _countof(pathToFile), "F:\\OACR\\Output\\%s.OacrWarnings.xml", buildNumber);
DWORD attributes = GetFileAttributesA(pathToFile);
bool oacrWarningsExist = (attributes != INVALID_FILE_ATTRIBUTES);
ASSERT_FALSE(oacrWarningsExist);
free(buildNumber);
}
}
#endif