test_tty_open_reenumerate.c [plain text]
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include "IOSerialTestLib.h"
#define MAX_PATH 256
int main(int argc, const char * argv[])
{
if (argc < 3) {
printf("Usage:\n"
"test_tty_open_reenumerate [path] [deviceid]\n");
return 0;
}
struct stat file_stat;
const char* path;
const char* deviceid;
if (strnlen(argv[1], MAX_PATH) == MAX_PATH) {
printf("[FAIL] test_tty_open_reenumerate: path length is too long\n");
return -1;
}
path = argv[1];
deviceid = argv[2];
if (-1 == stat(path, &file_stat)) {
printf("[FAIL] test_tty_open_reenumerate: file does not exist\n");
return -1;
}
if (-1 == testOpenReenumerate(path, deviceid)) {
goto fail;
}
printf("[PASS] test_tty_open_reenumerate\n");
return 0;
fail:
printf("[FAIL] test_tty_open_reenumerate\n");
return -1;
}