mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-22 21:23:07 +03:00
This allows requesting environment variable values set in the C++ test code, from python mock code. Use case is cross-checking test results against values expected by the host side part of the test.
61 lines
973 B
C++
61 lines
973 B
C++
#include "BSTest.h"
|
|
#include <stdio.h>
|
|
|
|
BS_ENV_DECLARE();
|
|
|
|
|
|
int main()
|
|
{
|
|
while(true) {
|
|
try{
|
|
BS_RUN();
|
|
return 0;
|
|
}catch(...) {
|
|
printf("Exception\n\n");
|
|
}
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
|
|
TEST_CASE("this test runs successfully", "[bluesmoke]")
|
|
{
|
|
CHECK(1 + 1 == 2);
|
|
REQUIRE(2 * 2 == 4);
|
|
}
|
|
|
|
TEST_CASE("another test which fails", "[bluesmoke][fail]")
|
|
{
|
|
CHECK(true);
|
|
CHECK(false);
|
|
CHECK(true);
|
|
CHECK(false);
|
|
}
|
|
|
|
TEST_CASE("another test which fails and crashes", "[bluesmoke][fail]")
|
|
{
|
|
CHECK(true);
|
|
REQUIRE(false);
|
|
}
|
|
|
|
|
|
TEST_CASE("third test which should be skipped", "[.]")
|
|
{
|
|
FAIL();
|
|
}
|
|
|
|
|
|
TEST_CASE("this test also runs successfully", "[bluesmoke]")
|
|
{
|
|
|
|
}
|
|
|
|
TEST_CASE("environment variables can be set and read from python", "[bluesmoke]")
|
|
{
|
|
const char* res = getenv("VAR_FROM_PYTHON");
|
|
REQUIRE(res != NULL);
|
|
CHECK(strcmp(res, "42") == 0);
|
|
setenv("VAR_FROM_TEST", "24", 1);
|
|
}
|
|
|