tools/testing/selftests/liveupdate/luo_stress_sessions.c

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/liveupdate/luo_stress_sessions.c
Extension
.c
Size
2706 bytes
Lines
103
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

if (s_fd < 0) {
			fail_exit("luo_create_session for '%s' at index %d",
				  name, i);
		}
	}

	ksft_print_msg("[STAGE 1] Successfully created %d sessions.\n",
		       NUM_SESSIONS);

	close(luo_fd);
	daemonize_and_wait();
}

/* Stage 2: Executed after the kexec reboot. */
static void run_stage_2(int luo_fd, int state_session_fd)
{
	int i, stage;

	ksft_print_msg("[STAGE 2] Starting post-kexec verification...\n");

	restore_and_read_stage(state_session_fd, STATE_MEMFD_TOKEN, &stage);
	if (stage != 2) {
		fail_exit("Expected stage 2, but state file contains %d",
			  stage);
	}

	ksft_print_msg("[STAGE 2] Retrieving and finishing %d sessions...\n",
		       NUM_SESSIONS);

	for (i = 0; i < NUM_SESSIONS; i++) {
		char name[LIVEUPDATE_SESSION_NAME_LENGTH];
		int s_fd;

		snprintf(name, sizeof(name), "many-test-%d", i);
		s_fd = luo_retrieve_session(luo_fd, name);
		if (s_fd < 0) {
			fail_exit("luo_retrieve_session for '%s' at index %d",
				  name, i);
		}

		if (luo_session_finish(s_fd) < 0) {
			fail_exit("luo_session_finish for '%s' at index %d",
				  name, i);
		}
		close(s_fd);
	}

	ksft_print_msg("[STAGE 2] Finalizing state session...\n");
	if (luo_session_finish(state_session_fd) < 0)
		fail_exit("luo_session_finish for state session");
	close(state_session_fd);

	ksft_print_msg("\n--- MANY-SESSIONS KEXEC TEST PASSED (%d sessions) ---\n",
		       NUM_SESSIONS);
}

int main(int argc, char *argv[])
{
	return luo_test(argc, argv, STATE_SESSION_NAME,
			run_stage_1, run_stage_2);
}

Annotation

Implementation Notes