mirror of
https://github.com/esp8266/Arduino.git
synced 2025-09-08 06:28:00 +03:00
Previously device tests included information such as access point SSID/password at compile time. This made it difficult to compile test binaries once and then send them to multiple test runners for execution. This change adds a command to the test library to set environment variable on the target device: “setenv key value”. C library setenv/getenv facility is used to store variables. Test runner, tests, and makefile are updated to use this functionality.
49 lines
821 B
C++
49 lines
821 B
C++
#ifndef BS_STDIO_H
|
|
#define BS_STDIO_H
|
|
|
|
#include <stdio.h>
|
|
#include <exception>
|
|
|
|
namespace bs
|
|
{
|
|
class StdIOHelper
|
|
{
|
|
public:
|
|
StdIOHelper()
|
|
{
|
|
}
|
|
|
|
size_t printf(const char *format, ...)
|
|
{
|
|
va_list arg;
|
|
va_start(arg, format);
|
|
size_t result = vprintf(format, arg);
|
|
va_end(arg);
|
|
return result;
|
|
}
|
|
|
|
size_t read_line(char* dest, size_t dest_size)
|
|
{
|
|
char* res = fgets(dest, dest_size, stdin);
|
|
if (res == NULL) {
|
|
return 0;
|
|
}
|
|
size_t len = strlen(dest);
|
|
if (dest[len - 1] == '\n') {
|
|
dest[len - 1] = 0;
|
|
len--;
|
|
}
|
|
return len;
|
|
}
|
|
};
|
|
|
|
typedef StdIOHelper IOHelper;
|
|
|
|
inline void fatal() {
|
|
throw std::runtime_error("fatal error");
|
|
}
|
|
|
|
} // namespace bs
|
|
|
|
#endif //BS_STDIO_H
|