1/**
2 * \file
3 * \brief Tests oct_read call
4 */
5
6/*
7 * Copyright (c) 2011, ETH Zurich.
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#include <stdio.h>
16#include <string.h>
17#include <stdlib.h>
18#include <assert.h>
19
20#include <barrelfish/barrelfish.h>
21#include <barrelfish/deferred.h>
22
23#include <skb/skb.h>
24#include <octopus/octopus.h>
25
26#include "common.h"
27
28int main(int argc, char *argv[])
29{
30    errval_t err = SYS_ERR_OK;
31    oct_init();
32
33    char* name = NULL;
34    char* attr1 = NULL;
35    double d;
36    uint64_t i;
37
38    err = oct_read("record", "%s", &name);
39    ASSERT_ERR_OK(err);
40    ASSERT_STRING(name, "record");
41    free(name);
42
43    err = oct_read("record {}", "%s {}", &name);
44    ASSERT_ERR_OK(err);
45    ASSERT_STRING(name, "record");
46    free(name);
47
48    err = oct_read("record { attr1: 'Test String 123' }", "%s { attr1: %s }", &name, &attr1);
49    ASSERT_STRING(name, "record");
50    ASSERT_STRING(attr1, "Test String 123");
51    ASSERT_ERR_OK(err);
52    free(name);
53    free(attr1);
54
55    err = oct_read("record2 { str: 'string', float: 12.0, integer: 1212}",
56    		"_ { float: %f, str: %s, integer: %d }", &d, &attr1, &i);
57    ASSERT_ERR_OK(err);
58    ASSERT_STRING(attr1, "string");
59    assert(d == 12.0);
60    assert(i == 1212);
61
62    return EXIT_SUCCESS;
63}
64