resetting manifest requested domain to floor
[platform/upstream/ccache.git] / test / test_stats.c
1 /*
2  * Copyright (C) 2010 Joel Rosdahl
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the Free
6  * Software Foundation; either version 3 of the License, or (at your option)
7  * any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc., 51
16  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18
19 /*
20  * This file contains tests for statistics handling.
21  */
22
23 #include "ccache.h"
24 #include "counters.h"
25 #include "test/framework.h"
26 #include "test/util.h"
27
28 TEST_SUITE(stats)
29
30 TEST(forward_compatibility)
31 {
32         unsigned i;
33         FILE *f;
34         struct counters *counters = counters_init(0);
35
36         f = fopen("stats", "w");
37         for (i = 0; i < 100; i++) {
38                 fprintf(f, "%u\n", i);
39         }
40         fclose(f);
41
42         stats_read("stats", counters);
43         CHECK_UNS_EQ(100, counters->size);
44         CHECK_UNS_EQ(73, counters->data[73]);
45
46         stats_write("stats", counters);
47         CHECK_UNS_EQ(100, counters->size);
48         CHECK_UNS_EQ(99, counters->data[99]);
49
50         counters_free(counters);
51 }
52
53 TEST_SUITE_END