1/**
2 * \file
3 * \brief Tests for octopus get/set/del API
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 <octopus/octopus.h>
22
23#include "common.h"
24
25int main(int argc, char *argv[])
26{
27    oct_init();
28
29    uint32_t id;
30
31    errval_t err = oct_sem_new(&id, 1);
32    ASSERT_ERR_OK(err);
33    debug_printf("Semaphore created with id=%"PRIu32"\n", id);
34
35    err = oct_sem_trywait(id);
36    ASSERT_ERR_OK(err);
37
38    err = oct_sem_trywait(id);
39    ASSERT_ERR(err, OCT_ERR_NO_RECORD);
40
41    err = oct_sem_post(id);
42    ASSERT_ERR_OK(err);
43
44    err = oct_sem_post(id);
45    ASSERT_ERR_OK(err);
46
47    err = oct_sem_trywait(id);
48    ASSERT_ERR_OK(err);
49
50    err = oct_sem_trywait(id);
51    ASSERT_ERR_OK(err);
52
53    err = oct_sem_trywait(id);
54    ASSERT_ERR(err, OCT_ERR_NO_RECORD);
55
56    printf("d2sem SUCCESS!\n");
57    return EXIT_SUCCESS;
58}
59