HelenOS sources
This source file includes following definitions.
- PCUT_TEST
- PCUT_TEST
- PCUT_TEST
#include <errno.h>
#include <pcut/pcut.h>
#include <stdio.h>
#include <str.h>
#include "../volume.h"
PCUT_INIT;
PCUT_TEST_SUITE(volume);
PCUT_TEST(volumes_basic)
{
vol_volumes_t *volumes;
char *namebuf;
char *fname;
errno_t rc;
int rv;
namebuf = malloc(L_tmpnam);
PCUT_ASSERT_NOT_NULL(namebuf);
fname = tmpnam(namebuf);
PCUT_ASSERT_NOT_NULL(fname);
rc = vol_volumes_create(fname, &volumes);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
vol_volumes_destroy(volumes);
rv = remove(fname);
PCUT_ASSERT_INT_EQUALS(0, rv);
free(fname);
}
PCUT_TEST(two_same_different)
{
vol_volumes_t *volumes;
vol_volume_t *va, *vb, *va1;
char *namebuf;
char *fname;
errno_t rc;
int rv;
namebuf = malloc(L_tmpnam);
PCUT_ASSERT_NOT_NULL(namebuf);
fname = tmpnam(namebuf);
PCUT_ASSERT_NOT_NULL(fname);
rc = vol_volumes_create(fname, &volumes);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = vol_volume_lookup_ref(volumes, "foo", &va);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = vol_volume_lookup_ref(volumes, "bar", &vb);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = vol_volume_lookup_ref(volumes, "foo", &va1);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_TRUE(va1 == va);
vol_volume_del_ref(va);
vol_volume_del_ref(vb);
vol_volume_del_ref(va1);
vol_volumes_destroy(volumes);
rv = remove(fname);
PCUT_ASSERT_INT_EQUALS(0, rv);
free(fname);
}
PCUT_TEST(same_twice)
{
vol_volumes_t *volumes;
vol_volume_t *va;
char *namebuf;
char *fname;
errno_t rc;
int rv;
namebuf = malloc(L_tmpnam);
PCUT_ASSERT_NOT_NULL(namebuf);
fname = tmpnam(namebuf);
PCUT_ASSERT_NOT_NULL(fname);
rc = vol_volumes_create(fname, &volumes);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = vol_volume_lookup_ref(volumes, "foo", &va);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
rc = vol_volume_set_mountp(va, "/xyz");
vol_volume_del_ref(va);
rc = vol_volume_lookup_ref(volumes, "foo", &va);
PCUT_ASSERT_ERRNO_VAL(EOK, rc);
PCUT_ASSERT_NOT_NULL(va->mountp);
PCUT_ASSERT_TRUE(str_cmp(va->mountp, "/xyz") == 0);
vol_volume_del_ref(va);
vol_volumes_destroy(volumes);
rv = remove(fname);
PCUT_ASSERT_INT_EQUALS(0, rv);
free(fname);
}
PCUT_EXPORT(volume);
HelenOS homepage, sources at GitHub