int_test_result.c 1008 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include <stdio.h>
  2. #include <sys/stat.h>
  3. #include <fcntl.h>
  4. #include <stdarg.h>
  5. #include "int_test_result.h"
  6. #define BASE_DIR "output"
  7. void mark_result(char *casename, char result)
  8. {
  9. char output_filename[256];
  10. int fd;
  11. if( result == RESULT_PASS )
  12. {
  13. sprintf(output_filename, "%s_PASS.txt", casename);
  14. printf("\n\n%s PASS\n\n", casename);
  15. }
  16. else
  17. {
  18. sprintf(output_filename, "%s_FAIL.txt", casename);
  19. printf("\n\n%s FAIL\n\n", casename);
  20. }
  21. if ((fd = open(output_filename,
  22. O_WRONLY | O_CREAT | O_TRUNC,
  23. S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) == -1)
  24. {
  25. perror("Cannot open output file\n");
  26. }
  27. close(fd);
  28. }
  29. void tlog(char *prefix, char * fmt, ...)
  30. {
  31. if( prefix && fmt )
  32. {
  33. va_list ap;
  34. va_start(ap, fmt);
  35. printf("%s (%d): ", prefix, time(NULL));
  36. vprintf(fmt, ap);
  37. printf("\n");
  38. va_end(ap);
  39. }
  40. }