static int g_seekCount;
static int g_writeCount;
static int g_circCount;
+static int g_appendCount;
static int g_lineCount = 2000;
static int g_recordLen = 64;
FILE *fd;
int x;
char string[80];
+ int sum;
+ int ret;
/* Try to open the file */
*/
printf("Writing test data. %d lines to write\n", g_lineCount);
- for (x = 0; x < g_lineCount; x++) {
+ for (sum = 0, x = 0; x < g_lineCount; x++) {
g_linePos[x] = ftell(fd);
sprintf(string, "This is line %d at offset %d\n", x, g_linePos[x]);
g_lineLen[x] = strlen(string);
- fprintf(fd, "%s", string);
+ ret = fprintf(fd, "%s", string);
+
+ if (ret) {
+ sum += ret;
+ } else {
+ printf("\n");
+ printf("%s is failed.(%d)", string, ret);
+ }
printf("\r%d", x);
fflush(stdout);
/* Close the file */
- printf("\r\nDone.\n");
+ if (x != g_lineCount) {
+ printf("\n");
+ printf("WARNING: Writing is failed. Only %d lines %d bytes was written\n", x - 1, sum);
+ printf("Maybe disk has been fulled.\n");
+ printf("Please check 'df' command to verify the filesystem usage.\n");
+ } else {
+ printf("\r\nDone.\n");
+ }
fclose(fd);
/* Now write some data to the end of the file */
fprintf(fd, "This is a test of the append.\n");
+ if (ferror(fd) != OK) {
+ printf("Error appending message... Maybe disk has been fulled\n");
+ return ERROR;
+ }
pos = ftell(fd);
/* Now seek to the end of the file and ensure that is where
g_writeCount = atoi(optarg);
break;
+ case 'a':
+ g_appendCount = atoi(optarg);
+ break;
+
default: /* '?' */
smart_usage();
exit(EXIT_FAILURE);
}
}
- if (argc < 2 || (g_seekCount + g_writeCount + g_circCount == 0)) {
+ if (argc < 2) {
smart_usage();
return -1;
}
/* Test if performing seek test or write test */
- if (g_seekCount > 0 || g_writeCount > 0) {
- /* Create a test file */
+ /* Create a test file */
- ret = smart_create_test_file(argv[optind]);
- if (ret < 0) {
- goto err_out_with_mem;
- }
+ ret = smart_create_test_file(argv[optind]);
+ if (ret < 0) {
+ goto err_out_with_mem;
+ }
+
+ if (g_seekCount > 0 || g_writeCount > 0 || g_appendCount > 0) {
/* Conduct a seek test? */
/* Conduct an append test */
- ret = smart_append_test(argv[optind]);
- if (ret < 0) {
- goto err_out_with_mem;
+ if (g_appendCount > 0) {
+ ret = smart_append_test(argv[optind]);
+ if (ret < 0) {
+ goto err_out_with_mem;
+ }
}
/* Conduct a seek with write test? */
/* Perform a "circular log" test */
- ret = smart_circular_log_test(argv[optind]);
- if (ret < 0) {
- goto err_out_with_mem;
+ if (g_circCount > 0) {
+ ret = smart_circular_log_test(argv[optind]);
+ if (ret < 0) {
+ goto err_out_with_mem;
+ }
}
err_out_with_mem: