Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SystemInformation_UnitTests.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
12 #include <stdlib.h>
13 
14 namespace {
15 
16 
17 TEUCHOS_UNIT_TEST( SystemInformation, Commands )
18 {
21  TEST_ASSERT(output.find("TeuchosCore_SystemInformation_UnitTests.exe") != std::string::npos);
22  }
23 }
24 
25 
26 TEUCHOS_UNIT_TEST( SystemInformation, EnvVariables ) {
27 
29  {
31  TEST_ASSERT(values.find("BLAH_BLAH") != values.end());
32  TEST_EQUALITY_CONST(values["BLAH_BLAH"], "NOT SET");
33  }
34 
35  setenv("BLAH_BLAH", "test", 1);
36  {
38  TEST_ASSERT(values.find("BLAH_BLAH") != values.end());
39  TEST_EQUALITY_CONST(values["BLAH_BLAH"], "test");
40  }
41  unsetenv("BLAH_BLAH");
42 }
43 
44 
45 TEUCHOS_UNIT_TEST( SystemInformation, CommonlyUsed ) {
48  TEST_ASSERT(values.find("lscpu") != values.end());
49  TEST_ASSERT(values.find("sensors") != values.end());
50 }
51 
52 } // namespace
RegistrationResult registerEnvironmentVariable(const std::string &variableName)
Register an environment variable that should be tracked.
#define TEST_ASSERT(v1)
Assert the given statement is true.
void initializeCollection()
Track commonly used environment variables and commands.
#define TEUCHOS_UNIT_TEST(TEST_GROUP, TEST_NAME)
Macro for defining a (non-templated) unit test.
Unit testing support.
#define TEST_EQUALITY_CONST(v1, v2)
Assert the equality of v1 and constant v2.
bool commandIsAvailable(const std::string &command)
Check whether a command is available on the system.
Collect information about the runtime environment.
std::string runCommandAndCaptureOutput(const std::string &command)
Run a command and capture its output.
std::map< std::string, std::string > collectSystemInformation()
Collect information about the system.