コード例 #1
0
ファイル: common.c プロジェクト: mgrzeschik/rauc
gboolean test_make_slot_user_writable(const gchar* path, const gchar* file) {
	gboolean res = FALSE;
	gchar *slotpath;
	gchar *mountpath;
	
	slotpath = g_build_filename(path, file, NULL);
	g_assert_nonnull(slotpath);

	mountpath = g_build_filename(path, "tmpmount", NULL);
	g_assert_nonnull(mountpath);

	if (!g_file_test(mountpath, G_FILE_TEST_IS_DIR)) {
		g_assert(test_mkdir_relative(path, "tmpmount", 0777) == 0);
	}

	test_mount(slotpath, mountpath);

	test_do_chmod(mountpath);

	r_umount(mountpath, NULL);

	res = TRUE;

	return res;
}
コード例 #2
0
ファイル: init.c プロジェクト: Avanznow/rtems
static void test_create_file_system(void)
{
  int rv;

  rv = mkdir(mnt, S_IRWXU | S_IRWXG | S_IRWXO);
  rtems_test_assert(rv == 0);

  rv = rtems_rfs_format(rda, &rfs_config);
  rtems_test_assert(rv == 0);

  test_mount(true);

  rv = mknod(file, S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO, 0);
  rtems_test_assert(rv == 0);

  rv = unmount(mnt);
  rtems_test_assert(rv == 0);
}
コード例 #3
0
int main(int argc, char** argv)
{
	printf("TRIE       TESTS\n");
	printf("==================\n\n");

	init (argc, argv);

	test_mount();
	test_minimaltrie();
	test_simple();
	test_us();
	test_cascading();
	test_root();
	test_default();
	test_modules();
	test_defaultonly();

	printf("\ntest_trie RESULTS: %d test(s) done. %d error(s).\n", nbTest, nbError);

	return nbError;
}
コード例 #4
0
ファイル: init.c プロジェクト: Avanznow/rtems
static void test_rofs(void)
{
  int rv;
  int fd;
  char buf [1];
  ssize_t n;

  test_mount(false);

  fd = open(file, O_RDONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
  rtems_test_assert(fd >= 0);

  n = read(fd, buf, sizeof(buf));
  rtems_test_assert(n == 0);

  errno = 0;
  n = write(fd, buf, sizeof(buf));
  rtems_test_assert(n == -1);
  rtems_test_assert(errno == EBADF);

  errno = 0;
  rv = ftruncate(fd, 0);
  rtems_test_assert(rv == -1);
  rtems_test_assert(errno == EINVAL);

  errno = 0;
  rv = fchmod(fd, 0);
  rtems_test_assert(rv == -1);
  rtems_test_assert(errno == EROFS);

  errno = 0;
  rv = fchown(fd, 0, 0);
  rtems_test_assert(rv == -1);
  rtems_test_assert(errno == EROFS);

  rv = close(fd);
  rtems_test_assert(rv == 0);

  errno = 0;
  fd = open(not_exist, O_RDONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
  rtems_test_assert(fd == -1);
  rtems_test_assert(errno == EROFS);

  errno = 0;
  rv = mknod(not_exist, S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO, 0);
  rtems_test_assert(rv == -1);
  rtems_test_assert(errno == EROFS);

  errno = 0;
  rv = mkdir(not_exist, S_IRWXU | S_IRWXG | S_IRWXO);
  rtems_test_assert(rv == -1);
  rtems_test_assert(errno == EROFS);

  errno = 0;
  rv = rename(file, not_exist);
  rtems_test_assert(rv == -1);
  rtems_test_assert(errno == EROFS);

  errno = 0;
  rv = link(file, not_exist);
  rtems_test_assert(rv == -1);
  rtems_test_assert(errno == EROFS);

  errno = 0;
  rv = unlink(file);
  rtems_test_assert(rv == -1);
  rtems_test_assert(errno == EROFS);

  errno = 0;
  rv = symlink(file, not_exist);
  rtems_test_assert(rv == -1);
  rtems_test_assert(errno == EROFS);

  rv = unmount(mnt);
  rtems_test_assert(rv == 0);
}