xref: /6.6.0/sigar/tests/t_sigar_mem.c (revision 42d0b984)
1/**
2 * Copyright (c) 2009, Sun Microsystems Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * - Redistributions of source code must retain the above copyright notice,
9 *   this list of conditions and the following disclaimer.
10 * - Redistributions in binary form must reproduce the above copyright notice,
11 *   this list of conditions and the following disclaimer in the documentation
12 *   and/or other materials provided with the distribution.
13 * - Neither the name of Sun Microsystems Inc. nor the names of its contributors
14 *   may be used to endorse or promote products derived from this software
15 *   without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29#include <sys/types.h>
30#ifdef HAVE_SYS_TIME_H
31#include <sys/time.h>
32#endif
33#ifdef HAVE_SYS_RESOURCE_H
34#include <sys/resource.h>
35#endif
36
37#include <assert.h>
38#include <stdlib.h>
39#include <stdio.h>
40#include <string.h>
41#include <errno.h>
42
43#include "sigar.h"
44#include "sigar_private.h"
45#include "sigar_format.h"
46#include "sigar_tests.h"
47
48
49TEST(test_sigar_mem_get) {
50        sigar_mem_t mem;
51        int status;
52
53        assert(SIGAR_OK == (status = sigar_mem_get(t, &mem)));
54
55        assert(mem.ram > 0);
56        assert(mem.total > 0);
57        assert(mem.used > 0);
58        assert(mem.free > 0);
59        assert(mem.actual_free > 0);
60        assert(mem.actual_used > 0);
61
62        return 0;
63}
64
65int main() {
66        sigar_t *t;
67        int err = 0;
68
69        assert(SIGAR_OK == sigar_open(&t));
70
71        test_sigar_mem_get(t);
72
73        sigar_close(t);
74
75        return err ? -1 : 0;
76}
77