Changeset a35b458 in mainline for uspace/app/testread/testread.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/testread/testread.c
r3061bc1 ra35b458 79 79 bool check_enabled = true; 80 80 bool progress = true; 81 81 82 82 if (argc < 2) { 83 83 printf(NAME ": Error, argument missing.\n"); … … 85 85 return 1; 86 86 } 87 87 88 88 /* Skip program name */ 89 89 --argc; ++argv; 90 90 91 91 if (argc > 0 && str_cmp(*argv, "--no-check") == 0) { 92 92 check_enabled = false; 93 93 --argc; ++argv; 94 94 } 95 95 96 96 if (argc > 0 && str_cmp(*argv, "--no-progress") == 0) { 97 97 progress = false; 98 98 --argc; ++argv; 99 99 } 100 100 101 101 if (argc != 1) { 102 102 printf(NAME ": Error, unexpected argument.\n"); … … 104 104 return 1; 105 105 } 106 106 107 107 file_name = *argv; 108 108 109 109 buf = calloc(BUFELEMS, sizeof(uint64_t)); 110 110 if (buf == NULL) { … … 112 112 return 1; 113 113 } 114 114 115 115 file = fopen(file_name, "r"); 116 116 if (file == NULL) { … … 118 118 return 1; 119 119 } 120 120 121 121 expected = 0; 122 122 offset = 0; … … 127 127 gettimeofday(&start_time, NULL); 128 128 prev_time = start_time; 129 129 130 130 while (!feof(file)) { 131 131 size_t elems = fread(buf, sizeof(uint64_t), BUFELEMS, file); … … 136 136 return 1; 137 137 } 138 138 139 139 for (i = 0; i < elems; i++) { 140 140 if (check_enabled && uint64_t_le2host(buf[i]) != expected) { … … 147 147 offset += sizeof(uint64_t); 148 148 } 149 149 150 150 if (progress && offset >= next_mark) { 151 151 struct timeval cur_time; 152 152 gettimeofday(&cur_time, NULL); 153 153 154 154 uint32_t last_run = cur_time.tv_sec - prev_time.tv_sec; 155 155 uint32_t total_time = cur_time.tv_sec - start_time.tv_sec; … … 166 166 } 167 167 } 168 168 169 169 struct timeval final_time; 170 170 gettimeofday(&final_time, NULL); 171 171 172 172 uint32_t total_run_time = final_time.tv_sec - start_time.tv_sec; 173 173 if (total_run_time > 0) { … … 178 178 offset/total_run_time); 179 179 } 180 180 181 181 fclose(file); 182 182 free(buf);
Note:
See TracChangeset
for help on using the changeset viewer.