metrics: read /sys/class/block/*/stat correctly
TEST=unit tests, manual tested on panther_embedded BUG=chromium:415118 Change-Id: I849a9b7849a27d29d9d24bb1575f113e43716bd5 Reviewed-on: https://chromium-review.googlesource.com/218504 Reviewed-by: Bertrand Simonnet <bsimonnet@chromium.org> Commit-Queue: Nathan Bullock <nathanbullock@google.com> Tested-by: Nathan Bullock <nathanbullock@google.com>
This commit is contained in:
parent
0be0f736d7
commit
dc1ef3c356
|
@ -495,7 +495,7 @@ bool MetricsDaemon::DiskStatsReadStats(uint64_t* read_sectors,
|
|||
LOG_IF(WARNING, nchars == sizeof(line))
|
||||
<< "line too long in " << diskstats_path_;
|
||||
line[nchars] = '\0';
|
||||
nitems = sscanf(line, "%*d %*d %" PRIu64 "d %*d %*d %*d %" PRIu64 "d",
|
||||
nitems = sscanf(line, "%*d %*d %" PRIu64 " %*d %*d %*d %" PRIu64,
|
||||
read_sectors, write_sectors);
|
||||
if (nitems == 2) {
|
||||
success = true;
|
||||
|
|
|
@ -36,8 +36,8 @@ using chromeos_metrics::PersistentIntegerMock;
|
|||
|
||||
static const char kFakeDiskStatsName[] = "fake-disk-stats";
|
||||
static const char kFakeDiskStatsFormat[] =
|
||||
" 1793 1788 %" PRIu64 "d 105580 "
|
||||
" 196 175 %" PRIu64 "d 30290 "
|
||||
" 1793 1788 %" PRIu64 " 105580 "
|
||||
" 196 175 %" PRIu64 " 30290 "
|
||||
" 0 44060 135850\n";
|
||||
static const uint64_t kFakeReadSectors[] = {80000, 100000};
|
||||
static const uint64_t kFakeWriteSectors[] = {3000, 4000};
|
||||
|
|
Loading…
Reference in New Issue