Skip to content

Commit

Permalink
Standardize on CxPlat over Cxplat (#6)
Browse files Browse the repository at this point in the history
The initial commits that use "Cxplat" diverge from the msquic convention
of "CxPlat". There was no reason for this divergence, so let's revert
that and use "CxPlat".
  • Loading branch information
nigriMSFT authored Apr 26, 2024
1 parent b3c37bd commit f27ab98
Show file tree
Hide file tree
Showing 12 changed files with 152 additions and 152 deletions.
12 changes: 6 additions & 6 deletions scripts/test.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<#
.SYNOPSIS
This script runs the Cxplat tests.
This script runs the CxPlat tests.
.PARAMETER Config
Specifies the build configuration to test.
Expand Down Expand Up @@ -173,19 +173,19 @@ if ("" -ne $ExtraArtifactDir -and $Kernel) {
}

# Path to the cxplattest executable.
$CxplatTest = $null
$CxPlatTest = $null
$KernelPath = $null;
if ($IsWindows) {
$CxplatTest = Join-Path $RootArtifactDir "cxplattest.exe"
$CxPlatTest = Join-Path $RootArtifactDir "cxplattest.exe"
$KernelPath = Join-Path $RootDir "\artifacts\bin\winkernel\$($Arch)_$($Config)"
} elseif ($IsLinux -or $IsMacOS) {
$CxplatTest = Join-Path $RootArtifactDir "cxplattest"
$CxPlatTest = Join-Path $RootArtifactDir "cxplattest"
} else {
Write-Error "Unsupported platform type!"
}

# Make sure the build is present.
if (!(Test-Path $CxplatTest)) {
if (!(Test-Path $CxPlatTest)) {
$BuildScriptPath = Join-Path $RootDir "scripts"
$BuildScriptPath = Join-Path $BuildScriptPath "build.ps1"
Write-Error "Build does not exist!`n `nRun the following to generate it:`n `n $BuildScriptPath -Config $Config -Arch $Arch`n"
Expand Down Expand Up @@ -254,5 +254,5 @@ for ($iteration = 1; $iteration -le $NumIterations; $iteration++) {
Write-Host "------- Iteration $iteration -------"
}
# Run the script.
Invoke-Expression ($RunTest + " -Path $CxplatTest " + $TestArguments)
Invoke-Expression ($RunTest + " -Path $CxPlatTest " + $TestArguments)
}
8 changes: 4 additions & 4 deletions src/test/CxplatTests.h → src/test/CxPlatTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@
Abstract:
Interface for the Platform Independent Cxplat Tests
Interface for the Platform Independent CxPlat Tests
--*/

#ifdef __cplusplus
extern "C" {
#endif

void CxplatTestInitialize();
void CxplatTestUninitialize();
void CxPlatTestInitialize();
void CxPlatTestUninitialize();

//
// Dummy Tests
//

void CxplatTestDummy();
void CxPlatTestDummy();


//
Expand Down
48 changes: 24 additions & 24 deletions src/test/bin/cxplat_driver_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
//#define CXPLAT_IOCTL_PATH "\\\\.\\\\" CXPLAT_DRIVER_NAME


class CxplatDriverService {
class CxPlatDriverService {
SC_HANDLE ScmHandle;
SC_HANDLE ServiceHandle;
public:
CxplatDriverService() :
CxPlatDriverService() :
ScmHandle(nullptr),
ServiceHandle(nullptr) {
}
Expand All @@ -34,7 +34,7 @@ class CxplatDriverService {
ScmHandle = OpenSCManager(nullptr, nullptr, SC_MANAGER_ALL_ACCESS);
if (ScmHandle == nullptr) {
Error = GetLastError();
CxplatTraceEvent(
CxPlatTraceEvent(
"[ lib] ERROR, %u, %s.",
Error,
"GetFullPathName failed");
Expand All @@ -47,15 +47,15 @@ class CxplatDriverService {
DriverName,
SERVICE_ALL_ACCESS);
if (ServiceHandle == nullptr) {
CxplatTraceEvent(
CxPlatTraceEvent(
"[ lib] ERROR, %u, %s.",
GetLastError(),
"OpenService failed");
char DriverFilePath[MAX_PATH] = {0};
GetModuleFileNameA(NULL, DriverFilePath, MAX_PATH);
char* PathEnd = strrchr(DriverFilePath, '\\');
if (!PathEnd) {
CxplatTraceEvent(
CxPlatTraceEvent(
"[ lib] ERROR, %s.",
"Failed to get currently executing module path");
return false;
Expand All @@ -69,13 +69,13 @@ class CxplatDriverService {
"%s.sys",
DriverName);
if (PathResult <= 0 || (size_t)PathResult > RemainingLength) {
CxplatTraceEvent(
CxPlatTraceEvent(
"[ lib] ERROR, %s.",
"Failed to create driver on disk file path");
return false;
}
if (GetFileAttributesA(DriverFilePath) == INVALID_FILE_ATTRIBUTES) {
CxplatTraceEvent(
CxPlatTraceEvent(
"[ lib] ERROR, %s.",
"Failed to find driver on disk");
return false;
Expand All @@ -100,7 +100,7 @@ class CxplatDriverService {
if (Error == ERROR_SERVICE_EXISTS) {
goto QueryService;
}
CxplatTraceEvent(
CxPlatTraceEvent(
"[ lib] ERROR, %u, %s.",
Error,
"CreateService failed");
Expand All @@ -121,7 +121,7 @@ class CxplatDriverService {
if (!StartServiceA(ServiceHandle, 0, nullptr)) {
unsigned long Error = GetLastError();
if (Error != ERROR_SERVICE_ALREADY_RUNNING) {
CxplatTraceEvent(
CxPlatTraceEvent(
"[ lib] ERROR, %u, %s.",
Error,
"StartService failed");
Expand All @@ -132,11 +132,11 @@ class CxplatDriverService {
}
};

class CxplatDriverClient {
class CxPlatDriverClient {
HANDLE DeviceHandle;
public:
CxplatDriverClient() : DeviceHandle(INVALID_HANDLE_VALUE) { }
~CxplatDriverClient() { Uninitialize(); }
CxPlatDriverClient() : DeviceHandle(INVALID_HANDLE_VALUE) { }
~CxPlatDriverClient() { Uninitialize(); }
bool Initialize(
_In_z_ const char* DriverName
) {
Expand All @@ -149,7 +149,7 @@ class CxplatDriverClient {
"\\\\.\\\\%s",
DriverName);
if (PathResult < 0 || PathResult >= sizeof(IoctlPath)) {
CxplatTraceEvent(
CxPlatTraceEvent(
"[ lib] ERROR, %s.",
"Creating Driver File Path failed");
return false;
Expand All @@ -165,7 +165,7 @@ class CxplatDriverClient {
nullptr);
if (DeviceHandle == INVALID_HANDLE_VALUE) {
Error = GetLastError();
CxplatTraceEvent(
CxPlatTraceEvent(
"[ lib] ERROR, %u, %s.",
Error,
"CreateFile failed");
Expand All @@ -191,13 +191,13 @@ class CxplatDriverClient {
Overlapped.hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
if (Overlapped.hEvent == nullptr) {
Error = GetLastError();
CxplatTraceEvent(
CxPlatTraceEvent(
"[ lib] ERROR, %u, %s.",
Error,
"CreateEvent failed");
return false;
}
CxplatTraceLogVerbose(
CxPlatTraceLogVerbose(
"[test] Sending Write IOCTL %u with %u bytes.",
IoGetFunctionCodeFromCtlCode(IoControlCode),
InBufferSize);
Expand All @@ -211,7 +211,7 @@ class CxplatDriverClient {
Error = GetLastError();
if (Error != ERROR_IO_PENDING) {
CloseHandle(Overlapped.hEvent);
CxplatTraceEvent(
CxPlatTraceEvent(
"[ lib] ERROR, %u, %s.",
Error,
"DeviceIoControl Write failed");
Expand All @@ -230,7 +230,7 @@ class CxplatDriverClient {
Error = ERROR_TIMEOUT;
CancelIoEx(DeviceHandle, &Overlapped);
}
CxplatTraceEvent(
CxPlatTraceEvent(
"[ lib] ERROR, %u, %s.",
Error,
"GetOverlappedResultEx Write failed");
Expand Down Expand Up @@ -267,13 +267,13 @@ class CxplatDriverClient {
Overlapped.hEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
if (!Overlapped.hEvent) {
Error = GetLastError();
CxplatTraceEvent(
CxPlatTraceEvent(
"[ lib] ERROR, %u, %s.",
Error,
"CreateEvent failed");
return false;
}
CxplatTraceLogVerbose(
CxPlatTraceLogVerbose(
"[test] Sending Read IOCTL %u.",
IoGetFunctionCodeFromCtlCode(IoControlCode));
if (!DeviceIoControl(
Expand All @@ -286,7 +286,7 @@ class CxplatDriverClient {
Error = GetLastError();
if (Error != ERROR_IO_PENDING) {
CloseHandle(Overlapped.hEvent);
CxplatTraceEvent(
CxPlatTraceEvent(
"[ lib] ERROR, %u, %s.",
Error,
"DeviceIoControl Write failed");
Expand All @@ -307,7 +307,7 @@ class CxplatDriverClient {
GetOverlappedResult(DeviceHandle, &Overlapped, &dwBytesReturned, true);
}
} else {
CxplatTraceEvent(
CxPlatTraceEvent(
"[ lib] ERROR, %u, %s.",
Error,
"GetOverlappedResultEx Read failed");
Expand All @@ -325,7 +325,7 @@ class CxplatDriverClient {

#define UNREFERENCED_PARAMETER(param)

class CxplatDriverService {
class CxPlatDriverService {
public:
bool Initialize(
_In_z_ const char* DriverName,
Expand All @@ -339,7 +339,7 @@ class CxplatDriverService {
bool Start() { return false; }
};

class CxplatDriverClient {
class CxPlatDriverClient {
public:
bool Initialize(
_In_z_ const char* DriverName
Expand Down
26 changes: 13 additions & 13 deletions src/test/bin/cxplat_gtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
bool TestingKernelMode = false;
const char* OsRunner = nullptr;
uint32_t Timeout = UINT32_MAX;
CxplatDriverClient DriverClient;
CxPlatDriverClient DriverClient;

class CxplatTestEnvironment : public ::testing::Environment {
CxplatDriverService DriverService;
class CxPlatTestEnvironment : public ::testing::Environment {
CxPlatDriverService DriverService;
public:
void SetUp() override {
if (TestingKernelMode) {
Expand All @@ -29,15 +29,15 @@ class CxplatTestEnvironment : public ::testing::Environment {
ASSERT_TRUE(DriverClient.Initialize(DriverName));
} else {
printf("Initializing for User Mode tests\n");
CxplatTestInitialize();
CxPlatTestInitialize();
}
}
void TearDown() override {
if (TestingKernelMode) {
DriverClient.Uninitialize();
DriverService.Uninitialize();
} else {
CxplatTestUninitialize();
CxPlatTestUninitialize();
}
}
};
Expand All @@ -61,7 +61,7 @@ LogTestFailure(
va_start(Args, Format);
(void)_vsnprintf_s(Buffer, sizeof(Buffer), _TRUNCATE, Format, Args);
va_end(Args);
CxplatTraceLogError(
CxPlatTraceLogError(
TestLogFailure,
"[test] FAILURE - %s:%d - %s",
File,
Expand All @@ -73,13 +73,13 @@ LogTestFailure(
struct TestLogger {
const char* TestName;
TestLogger(const char* Name) : TestName(Name) {
CxplatTraceLogInfo(
CxPlatTraceLogInfo(
TestCaseStart,
"[test] START %s",
TestName);
}
~TestLogger() {
CxplatTraceLogInfo(
CxPlatTraceLogInfo(
TestCaseEnd,
"[test] END %s",
TestName);
Expand All @@ -91,26 +91,26 @@ struct TestLoggerT {
const char* TestName;
TestLoggerT(const char* Name, const T& Params) : TestName(Name) {
std::ostringstream stream; stream << Params;
CxplatTraceLogInfo(
CxPlatTraceLogInfo(
TestCaseTStart,
"[test] START %s, %s",
TestName,
stream.str().c_str());
}
~TestLoggerT() {
CxplatTraceLogInfo(
CxPlatTraceLogInfo(
TestCaseTEnd,
"[test] END %s",
TestName);
}
};

TEST(DummySuite, Dummy) {
TestLogger Logger("CxplatTestDummy");
TestLogger Logger("CxPlatTestDummy");
if (TestingKernelMode) {
ASSERT_TRUE(DriverClient.Run(IOCTL_CXPLAT_RUN_DUMMY));
} else {
CxplatTestDummy();
CxPlatTestDummy();
}
}

Expand All @@ -127,7 +127,7 @@ int main(int argc, char** argv) {
}
}
}
::testing::AddGlobalTestEnvironment(new CxplatTestEnvironment);
::testing::AddGlobalTestEnvironment(new CxPlatTestEnvironment);
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
2 changes: 1 addition & 1 deletion src/test/bin/cxplat_gtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#endif

#include "cxplat.h"
#include "CxplatTests.h"
#include "CxPlatTests.h"
#include "cxplat_trace.h"
#include "cxplat_driver_helpers.h"
#undef min // gtest headers conflict with previous definitions of min/max.
Expand Down
Loading

0 comments on commit f27ab98

Please sign in to comment.