tools/testing/selftests/liveupdate/luo_test_utils.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/liveupdate/luo_test_utils.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/liveupdate/luo_test_utils.c
Extension
.c
Size
6476 bytes
Lines
291
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

switch (opt) {
		case 's':
			stage = atoi(optarg);
			if (stage != 1 && stage != 2)
				fail_exit("Invalid stage argument");
			break;
		default:
			fail_exit("Unknown argument");
		}
	}
	return stage;
}

int luo_test(int argc, char *argv[],
	     const char *state_session_name,
	     luo_test_stage1_fn stage1,
	     luo_test_stage2_fn stage2)
{
	int target_stage = parse_stage_args(argc, argv);
	int luo_fd = luo_open_device();
	int state_session_fd;
	int detected_stage;

	if (luo_fd < 0) {
		ksft_exit_skip("Failed to open %s. Is the luo module loaded?\n",
			       LUO_DEVICE);
	}

	state_session_fd = luo_retrieve_session(luo_fd, state_session_name);
	if (state_session_fd == -ENOENT)
		detected_stage = 1;
	else if (state_session_fd >= 0)
		detected_stage = 2;
	else
		fail_exit("Failed to check for state session");

	if (target_stage != detected_stage) {
		ksft_exit_fail_msg("Stage mismatch Requested --stage %d, but system is in stage %d.\n"
				   "(State session %s: %s)\n",
				   target_stage, detected_stage, state_session_name,
				   (detected_stage == 2) ? "EXISTS" : "MISSING");
	}

	if (target_stage == 1)
		stage1(luo_fd);
	else
		stage2(luo_fd, state_session_fd);

	return 0;
}

Annotation

Implementation Notes