example: auto restart int the linux hello world example

This commit is contained in:
Fu Hanxi 2021-09-23 09:27:17 +08:00
parent ba0481aabd
commit 811ed96042
2 changed files with 13 additions and 2 deletions

View File

@ -369,4 +369,5 @@ test_linux_example:
script:
- cd ${IDF_PATH}/examples/build_system/cmake/linux_host_app
- idf.py build
- build/linux_host_app.elf
- timeout 5 ./build/linux_host_app.elf >test.log || true
- grep "Restarting" test.log

View File

@ -8,13 +8,23 @@
*/
#include "stdio.h"
#include <unistd.h>
void app_main() {
printf("Hello, Host!\n");
while(1) {
printf("Hello, Host!\n");
for (int i = 10; i >= 0; i--) {
printf("Restarting in %d seconds...\n", i);
sleep(1);
}
}
}
int main(int argc, char **argv)
{
setbuf(stdout, NULL);
app_main();
return 0;
}