Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of OmniWheels by
test_env.cpp
00001 #include "test_env.h" 00002 00003 // Const strings used in test_end 00004 const char* TEST_ENV_START = "start"; 00005 const char* TEST_ENV_SUCCESS = "success"; 00006 const char* TEST_ENV_FAILURE = "failure"; 00007 const char* TEST_ENV_MEASURE = "measure"; 00008 const char* TEST_ENV_END = "end"; 00009 00010 00011 static void led_blink(PinName led, float delay) 00012 { 00013 if (led != NC) { 00014 DigitalOut myled(led); 00015 while (1) { 00016 myled = !myled; 00017 wait(delay); 00018 } 00019 } 00020 while(1); 00021 } 00022 00023 void notify_start() 00024 { 00025 printf("{{%s}}" NL, TEST_ENV_START); 00026 } 00027 00028 void notify_performance_coefficient(const char* measurement_name, const int value) 00029 { 00030 printf("{{%s;%s;%d}}" RCNL, TEST_ENV_MEASURE, measurement_name, value); 00031 } 00032 00033 void notify_performance_coefficient(const char* measurement_name, const unsigned int value) 00034 { 00035 printf("{{%s;%s;%u}}" RCNL, TEST_ENV_MEASURE, measurement_name, value); 00036 } 00037 00038 void notify_performance_coefficient(const char* measurement_name, const double value) 00039 { 00040 printf("{{%s;%s;%f}}" RCNL, TEST_ENV_MEASURE, measurement_name, value); 00041 } 00042 00043 void notify_completion(bool success) 00044 { 00045 printf("{{%s}}" NL "{{%s}}" NL, success ? TEST_ENV_SUCCESS : TEST_ENV_FAILURE, TEST_ENV_END); 00046 led_blink(LED1, success ? 1.0 : 0.1); 00047 } 00048 00049 bool notify_completion_str(bool success, char* buffer) 00050 { 00051 bool result = false; 00052 if (buffer) { 00053 sprintf(buffer, "{{%s}}" NL "{{%s}}" NL, success ? TEST_ENV_SUCCESS : TEST_ENV_FAILURE, TEST_ENV_END); 00054 result = true; 00055 } 00056 return result; 00057 } 00058 00059 // Host test auto-detection API 00060 void notify_host_test_name(const char *host_test) { 00061 if (host_test) { 00062 printf("{{host_test_name;%s}}" NL, host_test); 00063 } 00064 } 00065 00066 void notify_timeout(int timeout) { 00067 printf("{{timeout;%d}}" NL, timeout); 00068 } 00069 00070 void notify_test_id(const char *test_id) { 00071 if (test_id) { 00072 printf("{{test_id;%s}}" NL, test_id); 00073 } 00074 } 00075 00076 void notify_test_description(const char *description) { 00077 if (description) { 00078 printf("{{description;%s}}" NL, description); 00079 } 00080 } 00081 00082 00083 // -DMBED_BUILD_TIMESTAMP=1406208182.13 00084 unsigned int testenv_randseed() 00085 { 00086 unsigned int seed = 0; 00087 #ifdef MBED_BUILD_TIMESTAMP 00088 long long_seed = static_cast<long>(MBED_BUILD_TIMESTAMP); 00089 seed = long_seed & 0xFFFFFFFF; 00090 #endif /* MBED_BUILD_TIMESTAMP */ 00091 return seed; 00092 }
Generated on Fri Jul 22 2022 04:54:02 by
1.7.2
