/* Archive, with 10 reports in reverse order, checking progress. */
static void test111_progress(struct hsm_copyaction_private *hcp, size_t length)
{
	int rc;
	int i;
	struct hsm_extent he;
	struct hsm_current_action hca;

	for (i = 0; i < 10; i++) {
		he.offset = (9-i)*length/10;
		he.length = length/10;
		rc = llapi_hsm_action_progress(hcp, &he, length, 0);
		ASSERTF(rc == 0, "llapi_hsm_action_progress failed: %s",
			strerror(-rc));

		rc = llapi_hsm_current_action(testfile, &hca);
		ASSERTF(rc == 0, "llapi_hsm_current_action failed: %s",
			strerror(-rc));
		ASSERTF(hca.hca_state == HPS_RUNNING,
			"hca_state=%u", hca.hca_state);
		ASSERTF(hca.hca_action == HUA_ARCHIVE,
			"hca_state=%u", hca.hca_action);
		ASSERTF(hca.hca_location.length == (i+1)*length/10,
			"i=%d, length=%llu",
			i, (unsigned long long)hca.hca_location.length);
	}
}
/* Archive, with a report every byte, backwards. */
static void test102_progress(struct hsm_copyaction_private *hcp, size_t length)
{
	int i;
	int rc;
	struct hsm_extent he;
	struct hsm_current_action hca;

	/* Report progress. 1 byte at a time :) */
	for (i = length-1; i >= 0; i--) {
		he.offset = i;
		he.length = 1;
		rc = llapi_hsm_action_progress(hcp, &he, length, 0);
		ASSERTF(rc == 0, "llapi_hsm_action_progress failed: %s",
			strerror(-rc));
	}

	rc = llapi_hsm_current_action(testfile, &hca);
	ASSERTF(rc == 0, "llapi_hsm_current_action failed: %s",
		strerror(-rc));
	ASSERTF(hca.hca_state == HPS_RUNNING,
		"hca_state=%u", hca.hca_state);
	ASSERTF(hca.hca_action == HUA_ARCHIVE,
		"hca_state=%u", hca.hca_action);
	ASSERTF(hca.hca_location.length == length,
		"length=%llu", (unsigned long long)hca.hca_location.length);
}
void test9(void)
{
	struct llapi_layout *layout;
	int rc;

	layout = llapi_layout_alloc();
	ASSERTF(layout != NULL, "errno = %d\n", errno);

	errno = 0;
	rc = llapi_layout_pattern_set(layout, LLAPI_LAYOUT_INVALID);
	ASSERTF(rc == -1 && errno == EOPNOTSUPP, "rc = %d, errno = %d", rc,
		errno);

	errno = 0;
	rc = llapi_layout_pattern_set(NULL, LLAPI_LAYOUT_DEFAULT);
	ASSERTF(rc == -1 && errno == EINVAL, "rc = %d, errno = %d", rc,
		errno);

	errno = 0;
	rc = llapi_layout_pattern_set(layout, LLAPI_LAYOUT_DEFAULT);
	ASSERTF(rc == 0, "rc = %d, errno = %d", rc, errno);

	errno = 0;
	rc = llapi_layout_pattern_set(layout, LLAPI_LAYOUT_RAID0);
	ASSERTF(rc == 0, "rc = %d, errno = %d", rc, errno);

	llapi_layout_free(layout);
}
/* Archive, with 1 bogus report. */
static void test105_progress(struct hsm_copyaction_private *hcp, size_t length)
{
	int rc;
	struct hsm_extent he;
	struct hsm_current_action hca;

	he.offset = 2*length;
	he.length = 10*length;
	rc = llapi_hsm_action_progress(hcp, &he, length, 0);
	ASSERTF(rc == 0, "llapi_hsm_action_progress failed: %s",
		strerror(-rc));

	rc = llapi_hsm_current_action(testfile, &hca);
	ASSERTF(rc == 0, "llapi_hsm_current_action failed: %s",
		strerror(-rc));
	ASSERTF(hca.hca_state == HPS_RUNNING,
		"hca_state=%u", hca.hca_state);
	ASSERTF(hca.hca_action == HUA_ARCHIVE,
		"hca_state=%u", hca.hca_action);

	/* BUG - offset should be 2*length, or length should
	 * be 8*length */
	ASSERTF(hca.hca_location.length == 10*length,
		"length=%llu", (unsigned long long)hca.hca_location.length);
}
Example #5
0
static void helper_test20(int fd)
{
	int gid;
	int rc;

	gid = 1234;
	rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid);
	ASSERTF(rc == -1 && errno == ENOTTY, "unexpected retval: %d %s",
		rc, strerror(errno));

	gid = 0;
	rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid);
	ASSERTF(rc == -1 && errno == ENOTTY, "unexpected retval: %d %s",
		rc, strerror(errno));

	gid = 1;
	rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid);
	ASSERTF(rc == -1 && errno == ENOTTY, "unexpected retval: %d %s",
		rc, strerror(errno));

	gid = -1;
	rc = ioctl(fd, LL_IOC_GROUP_LOCK, gid);
	ASSERTF(rc == -1 && errno == ENOTTY, "unexpected retval: %d %s",
		rc, strerror(errno));
}
Example #6
0
/* Test lock / unlock on a directory */
static void test20(void)
{
	int fd;
	int rc;
	char dname[PATH_MAX];

	/* Try the mountpoint. Should fail. */
	fd = open(fsmountdir, O_RDONLY | O_DIRECTORY);
	ASSERTF(fd >= 0, "open failed for '%s': %s", mainpath, strerror(errno));
	helper_test20(fd);
	close(fd);

	/* Try .lustre/ . Should fail. */
	rc = snprintf(dname, sizeof(dname), "%s/.lustre", fsmountdir);
	ASSERTF(rc < sizeof(dname), "Name too long");

	fd = open(fsmountdir, O_RDONLY | O_DIRECTORY);
	ASSERTF(fd >= 0, "open failed for '%s': %s", mainpath, strerror(errno));
	helper_test20(fd);
	close(fd);

	/* A regular directory. */
	rc = mkdir(mainpath, 0600);
	ASSERTF(rc == 0, "mkdir failed for '%s': %s",
		mainpath, strerror(errno));

	fd = open(mainpath, O_RDONLY | O_DIRECTORY);
	ASSERTF(fd >= 0, "open failed for '%s': %s",
		mainpath, strerror(errno));
	helper_test20(fd);
	close(fd);
}
/* Test llapi_hsm_copytool_recv in non blocking mode */
int test5(void)
{
	int rc;
	int i;
	struct hsm_copytool_private *ctdata;
	struct hsm_action_list	*hal;
	int msgsize;

	rc = llapi_hsm_copytool_register(&ctdata, fsmountdir,
					 0, NULL, O_NONBLOCK);
	ASSERTF(rc == 0, "llapi_hsm_copytool_unregister failed: %s",
		strerror(-rc));

	/* Hopefully there is nothing lingering */
	for (i = 0; i < 1000; i++) {
		rc = llapi_hsm_copytool_recv(ctdata, &hal, &msgsize);
		ASSERTF(rc == -EWOULDBLOCK, "llapi_hsm_copytool_recv error: %s",
			strerror(-rc));
	}

	rc = llapi_hsm_copytool_unregister(&ctdata);
	ASSERTF(rc == 0, "llapi_hsm_copytool_unregister failed: %s",
		strerror(-rc));

	return 0;
}
void test4(void)
{
	int rc;
	uint64_t ost0;
	uint64_t ost1;
	uint64_t count;
	uint64_t size;
	const char *lfs = getenv("LFS");
	char mypool[LOV_MAXPOOLNAME + 1] = { '\0' };
	char cmd[4096];
	char path[PATH_MAX];

	snprintf(path, sizeof(path), "%s/%s", lustre_dir, T4FILE);

	if (lfs == NULL)
		lfs = "/usr/bin/lfs";

	rc = unlink(path);
	ASSERTF(rc == 0 || errno == ENOENT, "errno = %d", errno);

	snprintf(cmd, sizeof(cmd), "%s setstripe %s %s -c %d -S %d %s", lfs,
		 strlen(poolname) > 0 ? "-p" : "", poolname, T4_STRIPE_COUNT,
		 T4_STRIPE_SIZE, path);
	rc = system(cmd);
	ASSERTF(rc == 0, "system(%s): exit status %d", cmd, WEXITSTATUS(rc));

	errno = 0;
	struct llapi_layout *layout = llapi_layout_get_by_path(path, 0);
	ASSERTF(layout != NULL, "errno = %d", errno);

	rc = llapi_layout_stripe_count_get(layout, &count);
	ASSERTF(count == T4_STRIPE_COUNT, "%"PRIu64" != %d", count,
		T4_STRIPE_COUNT);

	rc = llapi_layout_stripe_size_get(layout, &size);
	ASSERTF(size == T4_STRIPE_SIZE, "%"PRIu64" != %d", size,
		T4_STRIPE_SIZE);

	rc = llapi_layout_pool_name_get(layout, mypool, sizeof(mypool));
	ASSERTF(rc == 0, "errno = %d", errno);
	rc = strcmp(mypool, poolname);
	ASSERTF(rc == 0, "%s != %s", mypool, poolname);

	rc = llapi_layout_ost_index_get(layout, 0, &ost0);
	ASSERTF(rc == 0, "errno = %d", errno);
	rc = llapi_layout_ost_index_get(layout, 1, &ost1);
	ASSERTF(rc == 0, "errno = %d", errno);
	ASSERTF(ost1 != ost0, "%"PRIu64" == %"PRIu64, ost0, ost1);

	llapi_layout_free(layout);
}
void __test1_helper(struct llapi_layout *layout)
{
	uint64_t ost0;
	uint64_t ost1;
	uint64_t size;
	uint64_t count;
	int rc;
	char mypool[LOV_MAXPOOLNAME + 1] = { '\0' };

	rc = llapi_layout_stripe_count_get(layout, &count);
	ASSERTF(count == T0_STRIPE_COUNT, "%"PRIu64" != %d", count,
		T0_STRIPE_COUNT);

	rc = llapi_layout_stripe_size_get(layout, &size);
	ASSERTF(size == T0_STRIPE_SIZE, "%"PRIu64" != %d", size,
		T0_STRIPE_SIZE);

	rc = llapi_layout_pool_name_get(layout, mypool, sizeof(mypool));
	ASSERTF(rc == 0, "errno = %d", errno);
	rc = strcmp(mypool, poolname);
	ASSERTF(rc == 0, "%s != %s", mypool, poolname);

	rc = llapi_layout_ost_index_get(layout, 0, &ost0);
	ASSERTF(rc == 0, "errno = %d", errno);
	rc = llapi_layout_ost_index_get(layout, 1, &ost1);
	ASSERTF(rc == 0, "errno = %d", errno);
	ASSERTF(ost0 == T0_OST_OFFSET, "%"PRIu64" != %d", ost0, T0_OST_OFFSET);
	ASSERTF(ost1 != ost0, "%"PRIu64" == %"PRIu64, ost0, ost1);
}
Example #10
0
/* Lock / unlock a volatile file, with different creation flags */
static void test12(void)
{
	int rc;
	int fd;
	int gid;

	rc = mkdir(mainpath, 0600);
	ASSERTF(rc == 0, "mkdir failed for '%s': %s",
		mainpath, strerror(errno));

	fd = llapi_create_volatile_idx(mainpath, -1, O_CREAT | O_WRONLY);
	ASSERTF(fd >= 0, "llapi_create_volatile_idx failed on '%s': %s",
		mainpath, strerror(-fd));

	gid = 34895;
	rc = llapi_group_lock(fd, gid);
	ASSERTF(rc == 0, "cannot lock '%s': %s", mainpath, strerror(-rc));

	rc = llapi_group_unlock(fd, gid);
	ASSERTF(rc == 0, "cannot unlock '%s': %s", mainpath, strerror(-rc));

	close(fd);

	fd = llapi_create_volatile_idx(mainpath, -1,
				       O_CREAT | O_WRONLY | O_LOV_DELAY_CREATE);
	ASSERTF(fd >= 0, "llapi_create_volatile_idx failed on '%s': %s",
		mainpath, strerror(-fd));

	gid = 3354895;
	rc = llapi_group_lock(fd, gid);
	ASSERTF(rc == 0, "cannot lock '%s': %s", mainpath, strerror(-rc));

	rc = llapi_group_unlock(fd, gid);
	ASSERTF(rc == 0, "cannot unlock '%s': %s", mainpath, strerror(-rc));

	close(fd);

	fd = llapi_create_volatile_idx(mainpath, -1, O_RDONLY);
	ASSERTF(fd >= 0, "llapi_create_volatile_idx failed on '%s': %s",
		mainpath, strerror(-fd));

	gid = 3489655;
	rc = llapi_group_lock(fd, gid);
	ASSERTF(rc == 0, "cannot lock '%s': %s", mainpath, strerror(-rc));

	rc = llapi_group_unlock(fd, gid);
	ASSERTF(rc == 0, "cannot unlock '%s': %s", mainpath, strerror(-rc));

	close(fd);
}
Example #11
0
void test5(void)
{
	int rc;
	char path[PATH_MAX];
	struct llapi_layout *layout;

	snprintf(path, sizeof(path), "%s/%s", lustre_dir, T5FILE);

	rc = unlink(path);
	ASSERTF(rc == 0 || errno == ENOENT, "errno = %d", errno);

	errno = 0;
	layout = llapi_layout_get_by_path(path, 0);
	ASSERTF(layout == NULL && errno == ENOENT, "errno = %d", errno);
}
static void display_device_release(stm_display_device_t *dev)
{
  struct private_display_device_s *private_dev = (struct private_display_device_s*)dev;

  g_pIOS->DownSemaphore(dev->lock);

  ASSERTF((private_dev->use_count > 0),("%s: Too many release calls\n",__FUNCTION__));

  private_dev->use_count--;

  if(private_dev->use_count > 0)
  {
    g_pIOS->UpSemaphore(dev->lock);
    return;
  }

  delete (CDisplayDevice *)dev->handle;
  dev->handle = 0;

  numDevices--;

  g_pIOS->DeleteSemaphore(dev->lock);
  dev->lock = 0;

  if(numDevices == 0)
  {
    for(unsigned int i=0;i<maxBlitters;i++)
      g_pIOS->DeleteSemaphore(blitterLocks[i]);

    g_pIDebug->Release();
    g_pIOS->Release();
  }
}
Example #13
0
int main(int argc, char *argv[])
{
	char fsname[8 + 1];
	int rc;

	process_args(argc, argv);
	if (lustre_dir == NULL)
		lustre_dir = "/mnt/lustre";

	rc = llapi_search_mounts(lustre_dir, 0, fsmountdir, fsname);
	if (rc != 0) {
		fprintf(stderr, "Error: '%s': not a Lustre filesystem\n",
			lustre_dir);
		return EXIT_FAILURE;
	}

	/* Play nice with Lustre test scripts. Non-line buffered output
	 * stream under I/O redirection may appear incorrectly. */
	setvbuf(stdout, NULL, _IOLBF, 0);

	/* Create a test filename and reuse it. Remove possibly old files. */
	rc = snprintf(mainpath, sizeof(mainpath), "%s/%s", lustre_dir, maindir);
	ASSERTF(rc > 0 && rc < sizeof(mainpath), "invalid name for mainpath");
	cleanup();

	atexit(cleanup);

	PERFORM(test10);
	PERFORM(test11);
	PERFORM(test12);
	PERFORM(test20);
	PERFORM(test30);

	return EXIT_SUCCESS;
}
Resource platformLoadInternalResource(const char* path)
{
    RLOGI("Trying to internal load file %s", path);
	auto mgr  = gApp->activity->assetManager;
	auto asset = AAssetManager_open(mgr, path, AASSET_MODE_RANDOM);
	ASSERTF(asset != 0, "The asset %s does not exist", path);

	auto length = AAsset_getLength(asset);
	auto buffer = new uint8_t[length];
	auto err = AAsset_read(asset, buffer, length);

	ASSERTF(err >= 0, "Failed to load internal resource %s. Error was: %d", path, err);
	AAsset_close(asset);

	return (Resource){ buffer, (uint32_t)length };
}
Example #15
0
void test19(void)
{
	struct llapi_layout *layout;
	char *name = "0123456789abcde";
	char mypool[LOV_MAXPOOLNAME + 1] = { '\0' };
	int rc;

	layout = llapi_layout_alloc();
	ASSERTF(layout != NULL, "errno = %d", errno);
	rc = llapi_layout_pool_name_set(layout, name);
	ASSERTF(rc == 0, "errno = %d", errno);
	rc = llapi_layout_pool_name_get(layout, mypool, sizeof(mypool));
	ASSERTF(strlen(name) == strlen(mypool), "name = %s, str = %s", name,
		mypool);
	llapi_layout_free(layout);
}
Example #16
0
void ShaderProgramBase::UseProgramBase(const ShaderState& ss) const
{
    ASSERT_MAIN_THREAD();
    ASSERTF(isLoaded(), "%s", m_name.c_str());
    glReportError();
    glUseProgram(m_programHandle);
    glUniformMatrix4fv(m_transformUniform, 1, GL_FALSE, &ss.uTransform[0][0]);
    glReportError();
}
Example #17
0
GLint ShaderProgramBase::getUniformLocation(const char *name) const
{
    if (!isLoaded())
        return -1;
    GLint v = glGetUniformLocation(m_programHandle, name);
    ASSERTF(v >= 0, "%s::%s", m_name.c_str(), name);
    glReportError();
    return v;
}
/* Test llapi_hsm_current_action */
void test52(void)
{
	int rc;
	int fd;
	struct hsm_current_action hca;

	/* No fd equivalent, so close it. */
	fd = create_testfile(100);
	close(fd);

	rc = llapi_hsm_current_action(testfile, &hca);
	ASSERTF(rc == 0, "llapi_hsm_current_action failed: %s", strerror(-rc));
	ASSERTF(hca.hca_state, "hca_state=%u", hca.hca_state);
	ASSERTF(hca.hca_action, "hca_state=%u", hca.hca_action);

	rc = llapi_hsm_current_action(testfile, NULL);
	ASSERTF(rc == -EFAULT, "llapi_hsm_current_action failed: %s",
		strerror(-rc));
}
/* Bad parameters to llapi_hsm_copytool_unregister(). */
int test4(void)
{
	int rc;

	rc = llapi_hsm_copytool_unregister(NULL);
	ASSERTF(rc == -EINVAL, "llapi_hsm_copytool_unregister error: %s",
		strerror(-rc));

	return 0;
}
Example #20
0
void test1(void)
{
	char path[PATH_MAX];

	snprintf(path, sizeof(path), "%s/%s", lustre_dir, T0FILE);
	struct llapi_layout *layout = llapi_layout_get_by_path(path, 0);
	ASSERTF(layout != NULL, "errno = %d", errno);
	__test1_helper(layout);
	llapi_layout_free(layout);
}
Example #21
0
void test2(void)
{
	int fd;
	int rc;
	char path[PATH_MAX];

	snprintf(path, sizeof(path), "%s/%s", lustre_dir, T0FILE);

	fd = open(path, O_RDONLY);
	ASSERTF(fd >= 0, "open(%s): errno = %d", path, errno);

	struct llapi_layout *layout = llapi_layout_get_by_fd(fd, 0);
	ASSERTF(layout != NULL, "errno = %d", errno);

	rc = close(fd);
	ASSERTF(rc == 0, "close(%s): errno = %d", path, errno);

	__test1_helper(layout);
	llapi_layout_free(layout);
}
Example #22
0
void test14(void)
{
	int rc;
	struct llapi_layout *layout = llapi_layout_alloc();

	/* NULL path */
	errno = 0;
	rc = llapi_layout_file_create(NULL, 0, 0, layout);
	ASSERTF(rc == -1 && errno == EINVAL, "rc = %d, errno = %d", rc, errno);

	llapi_layout_free(layout);
}
/* Register and unregister 2000 times. Ensures there is no fd leak
 * since there is usually 1024 fd per process. */
int test1(void)
{
	int i;
	int rc;
	struct hsm_copytool_private *ctdata;

	for (i = 0; i < 2000; i++) {
		rc = llapi_hsm_copytool_register(&ctdata, fsmountdir,
						 0, NULL, 0);
		ASSERTF(rc == 0,
			"llapi_hsm_copytool_register failed: %s, loop=%d",
			strerror(-rc), i);

		rc = llapi_hsm_copytool_unregister(&ctdata);
		ASSERTF(rc == 0,
			"llapi_hsm_copytool_unregister failed: %s, loop=%d",
			strerror(-rc), i);
	}

	return 0;
}
Example #24
0
void test3(void)
{
	int rc;
	struct llapi_layout *layout;
	struct lu_fid fid;
	char fidstr[4096];
	char path[PATH_MAX];

	snprintf(path, sizeof(path), "%s/%s", lustre_dir, T0FILE);

	rc = llapi_path2fid(path, &fid);
	ASSERTF(rc == 0, "rc = %d, errno = %d", rc, errno);
	snprintf(fidstr, sizeof(fidstr), "0x%"PRIx64":0x%x:0x%x",
		 (uint64_t)fid.f_seq, fid.f_oid, fid.f_ver);
	errno = 0;
	layout = llapi_layout_get_by_fid(path, &fid, 0);
	ASSERTF(layout != NULL, "fidstr = %s, errno = %d", fidstr, errno);

	__test1_helper(layout);
	llapi_layout_free(layout);
}
/* Test llapi_hsm_copytool_recv with bogus parameters */
int test6(void)
{
	struct hsm_copytool_private *ctdata;
	struct hsm_action_list *hal;
	int rc;
	int msgsize;

	rc = llapi_hsm_copytool_register(&ctdata, fsmountdir, 0, NULL, 0);
	ASSERTF(rc == 0, "llapi_hsm_copytool_unregister failed: %s",
		strerror(-rc));

	rc = llapi_hsm_copytool_recv(NULL, &hal, &msgsize);
	ASSERTF(rc == -EINVAL, "llapi_hsm_copytool_recv error: %s",
		strerror(-rc));

	rc = llapi_hsm_copytool_recv(ctdata, NULL, &msgsize);
	ASSERTF(rc == -EINVAL, "llapi_hsm_copytool_recv error: %s",
		strerror(-rc));

	rc = llapi_hsm_copytool_recv(ctdata, &hal, NULL);
	ASSERTF(rc == -EINVAL, "llapi_hsm_copytool_recv error: %s",
		strerror(-rc));

	rc = llapi_hsm_copytool_recv(ctdata, NULL, NULL);
	ASSERTF(rc == -EINVAL, "llapi_hsm_copytool_recv error: %s",
		strerror(-rc));

	rc = llapi_hsm_copytool_unregister(&ctdata);
	ASSERTF(rc == 0, "llapi_hsm_copytool_unregister failed: %s",
		strerror(-rc));

	return 0;
}
Example #26
0
void test18(void)
{
	int rc;
	int fd;
	struct llapi_layout *layout = llapi_layout_alloc();
	char path[PATH_MAX];
	char pool[LOV_MAXPOOLNAME*2 + 1];
	char mypool[LOV_MAXPOOLNAME + 1] = { '\0' };

	snprintf(pool, sizeof(pool), "lustre.%s", poolname);

	snprintf(path, sizeof(path), "%s/%s", lustre_dir, T18FILE);

	ASSERTF(layout != NULL, "errno = %d", errno);

	rc = unlink(path);
	ASSERTF(rc == 0 || errno == ENOENT, "errno = %d", errno);

	rc = llapi_layout_pool_name_set(layout, pool);
	ASSERTF(rc == 0, "errno = %d", errno);

	rc = llapi_layout_pool_name_get(layout, mypool, sizeof(mypool));
	ASSERTF(rc == 0, "errno = %d", errno);
	rc = strcmp(mypool, poolname);
	ASSERTF(rc == 0, "%s != %s", mypool, poolname);
	fd = llapi_layout_file_create(path, 0, 0640, layout);
	ASSERTF(fd >= 0, "errno = %d", errno);
	rc = close(fd);
	ASSERTF(rc == 0, "errno = %d", errno);

	llapi_layout_free(layout);

	layout = llapi_layout_get_by_path(path, 0);
	ASSERTF(layout != NULL, "errno = %d", errno);
	rc = llapi_layout_pool_name_get(layout, mypool, sizeof(mypool));
	ASSERTF(rc == 0, "errno = %d", errno);
	rc = strcmp(mypool, poolname);
	ASSERTF(rc == 0, "%s != %s", mypool, poolname);
	llapi_layout_free(layout);
}
Resource platformLoadAbsolutePath(const char* resourcePath)
{
    auto file = fopen(resourcePath, "r+");
    ASSERTF(file != 0, "Couldn't open file. %s", resourcePath);
    fseek( file, 0L, SEEK_END);
    auto length = ftell(file);
    rewind(file);
    auto buffer = new uint8_t[length];
    fread(buffer, length, 1, file);
    fclose(file);
    RLOGI("%s", "Successfully loaded!");
    return (Resource){ buffer, (uint32_t)length };
}
/* Archive, with 1 bogus report. */
static void test107_progress(struct hsm_copyaction_private *hcp, size_t length)
{
	int rc;
	struct hsm_extent he;
	struct hsm_current_action hca;

	he.offset = -1;
	he.length = 10;
	rc = llapi_hsm_action_progress(hcp, &he, length, 0);
	ASSERTF(rc == -EINVAL, "llapi_hsm_action_progress error: %s",
		strerror(-rc));

	rc = llapi_hsm_current_action(testfile, &hca);
	ASSERTF(rc == 0, "llapi_hsm_current_action failed: %s",
		strerror(-rc));
	ASSERTF(hca.hca_state == HPS_RUNNING,
		"hca_state=%u", hca.hca_state);
	ASSERTF(hca.hca_action == HUA_ARCHIVE,
		"hca_state=%u", hca.hca_action);
	ASSERTF(hca.hca_location.length == 0,
		"length=%llu", (unsigned long long)hca.hca_location.length);
}
Example #29
0
void test17(void)
{
	int rc;
	int fd;
	int osts_all;
	uint64_t osts_layout;
	struct llapi_layout *layout;
	char path[PATH_MAX];

	snprintf(path, sizeof(path), "%s/%s", lustre_dir, T17FILE);

	rc = unlink(path);
	ASSERTF(rc == 0 || errno == ENOENT, "errno = %d", errno);
	layout = llapi_layout_alloc();
	ASSERTF(layout != NULL, "errno = %d", errno);
	rc = llapi_layout_stripe_count_set(layout, LLAPI_LAYOUT_WIDE);
	ASSERTF(rc == 0, "errno = %d", errno);
	fd = llapi_layout_file_create(path, 0, 0640, layout);
	ASSERTF(fd >= 0, "errno = %d", errno);
	rc = close(fd);
	ASSERTF(rc == 0, "errno = %d", errno);
	llapi_layout_free(layout);

	/* Get number of available OSTs */
	fd = open(path, O_RDONLY);
	ASSERTF(fd >= 0, "errno = %d", errno);
	rc = llapi_lov_get_uuids(fd, NULL, &osts_all);
	ASSERTF(rc == 0, "rc = %d, errno = %d", rc, errno);
	rc = close(fd);
	ASSERTF(rc == 0, "errno = %d", errno);

	layout = llapi_layout_get_by_path(path, 0);
	ASSERTF(layout != NULL, "errno = %d", errno);
	rc = llapi_layout_stripe_count_get(layout, &osts_layout);
	ASSERTF(osts_layout == osts_all, "%"PRIu64" != %d", osts_layout,
		osts_all);

	llapi_layout_free(layout);
}
Example #30
0
void test8(void)
{
	int fd;
	int rc;
	struct llapi_layout *layout;
	uint64_t count;
	uint64_t size;
	uint64_t pattern;
	char path[PATH_MAX];

	snprintf(path, sizeof(path), "%s/%s", lustre_dir, T8FILE);

	rc = unlink(path);
	ASSERTF(rc >= 0 || errno == ENOENT, "errno = %d", errno);
	fd = open(path, O_CREAT, 0640);
	ASSERTF(fd >= 0, "errno = %d", errno);
	rc = close(fd);
	ASSERTF(rc == 0, "errno = %d", errno);

	layout = llapi_layout_get_by_path(path, 0);
	ASSERTF(layout != NULL, "errno = %d\n", errno);

	rc = llapi_layout_stripe_count_get(layout, &count);
	ASSERTF(rc == 0, "errno = %d\n", errno);
	ASSERTF(count == LLAPI_LAYOUT_DEFAULT, "count = %"PRIu64"\n", count);

	rc = llapi_layout_stripe_size_get(layout, &size);
	ASSERTF(rc == 0, "errno = %d\n", errno);
	ASSERTF(size == LLAPI_LAYOUT_DEFAULT, "size = %"PRIu64"\n", size);

	rc = llapi_layout_pattern_get(layout, &pattern);
	ASSERTF(rc == 0, "errno = %d\n", errno);
	ASSERTF(pattern == LLAPI_LAYOUT_DEFAULT, "pattern = %"PRIu64"\n",
		pattern);

	llapi_layout_free(layout);
}