static void kgdbts_run_tests(void)
{
	char *ptr;
	int fork_test = 0;
	int do_sys_open_test = 0;
	int sstep_test = 1000;
	int nmi_sleep = 0;
	int i;

	ptr = strchr(config, 'F');
	if (ptr)
		fork_test = simple_strtol(ptr + 1, NULL, 10);
	ptr = strchr(config, 'S');
	if (ptr)
		do_sys_open_test = simple_strtol(ptr + 1, NULL, 10);
	ptr = strchr(config, 'N');
	if (ptr)
		nmi_sleep = simple_strtol(ptr+1, NULL, 10);
	ptr = strchr(config, 'I');
	if (ptr)
		sstep_test = simple_strtol(ptr+1, NULL, 10);

	/* required internal KGDB tests */
	v1printk("kgdbts:RUN plant and detach test\n");
	run_plant_and_detach_test(0);
	v1printk("kgdbts:RUN sw breakpoint test\n");
	run_breakpoint_test(0);
	v1printk("kgdbts:RUN bad memory access test\n");
	run_bad_read_test();
	v1printk("kgdbts:RUN singlestep test %i iterations\n", sstep_test);
	for (i = 0; i < sstep_test; i++) {
		run_singlestep_break_test();
		if (i % 100 == 0)
			v1printk("kgdbts:RUN singlestep [%i/%i]\n",
				 i, sstep_test);
	}

	/* ===Optional tests=== */

	/* All HW break point tests */
	if (arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT) {
		hwbreaks_ok = 1;
		v1printk("kgdbts:RUN hw breakpoint test\n");
		run_breakpoint_test(1);
		v1printk("kgdbts:RUN hw write breakpoint test\n");
		run_hw_break_test(1);
		v1printk("kgdbts:RUN access write breakpoint test\n");
		run_hw_break_test(0);
	}

	if (nmi_sleep) {
		v1printk("kgdbts:RUN NMI sleep %i seconds test\n", nmi_sleep);
		run_nmi_sleep_test(nmi_sleep);
	}

#ifdef CONFIG_DEBUG_RODATA
	/* Until there is an api to write to read-only text segments, use
	 * HW breakpoints for the remainder of any tests, else print a
	 * failure message if hw breakpoints do not work.
	 */
	if (!(arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT && hwbreaks_ok)) {
		eprintk("kgdbts: HW breakpoints do not work,"
			"skipping remaining tests\n");
		return;
	}
	force_hwbrks = 1;
#endif /* CONFIG_DEBUG_RODATA */

	/* If the do_fork test is run it will be the last test that is
	 * executed because a kernel thread will be spawned at the very
	 * end to unregister the debug hooks.
	 */
	if (fork_test) {
		repeat_test = fork_test;
		printk(KERN_INFO "kgdbts:RUN do_fork for %i breakpoints\n",
			repeat_test);
		kthread_run(kgdbts_unreg_thread, NULL, "kgdbts_unreg");
		run_do_fork_test();
		return;
	}

	/* If the sys_open test is run it will be the last test that is
	 * executed because a kernel thread will be spawned at the very
	 * end to unregister the debug hooks.
	 */
	if (do_sys_open_test) {
		repeat_test = do_sys_open_test;
		printk(KERN_INFO "kgdbts:RUN sys_open for %i breakpoints\n",
			repeat_test);
		kthread_run(kgdbts_unreg_thread, NULL, "kgdbts_unreg");
		run_sys_open_test();
		return;
	}
	/* Shutdown and unregister */
	kgdb_unregister_io_module(&kgdbts_io_ops);
	configured = 0;
}
示例#2
0
static void kgdbts_run_tests(void)
{
	char *ptr;
	int fork_test = 0;
	int do_sys_open_test = 0;
	int sstep_test = 1000;
	int nmi_sleep = 0;
	int i;

	ptr = strchr(config, 'F');
	if (ptr)
		fork_test = simple_strtol(ptr + 1, NULL, 10);
	ptr = strchr(config, 'S');
	if (ptr)
		do_sys_open_test = simple_strtol(ptr + 1, NULL, 10);
	ptr = strchr(config, 'N');
	if (ptr)
		nmi_sleep = simple_strtol(ptr+1, NULL, 10);
	ptr = strchr(config, 'I');
	if (ptr)
		sstep_test = simple_strtol(ptr+1, NULL, 10);

	/* All HW break point tests */
	if (arch_kgdb_ops.flags & KGDB_HW_BREAKPOINT) {
		hwbreaks_ok = 1;
		v1printk("kgdbts:RUN hw breakpoint test\n");
		run_breakpoint_test(1);
		v1printk("kgdbts:RUN hw write breakpoint test\n");
		run_hw_break_test(1);
		v1printk("kgdbts:RUN access write breakpoint test\n");
		run_hw_break_test(0);
	}

	/* required internal KGDB tests */
	v1printk("kgdbts:RUN plant and detach test\n");
	run_plant_and_detach_test(0);
	v1printk("kgdbts:RUN sw breakpoint test\n");
	run_breakpoint_test(0);
	v1printk("kgdbts:RUN bad memory access test\n");
	run_bad_read_test();
	v1printk("kgdbts:RUN singlestep test %i iterations\n", sstep_test);
	for (i = 0; i < sstep_test; i++) {
		run_singlestep_break_test();
		if (i % 100 == 0)
			v1printk("kgdbts:RUN singlestep [%i/%i]\n",
				 i, sstep_test);
	}

	/* ===Optional tests=== */

	if (nmi_sleep) {
		v1printk("kgdbts:RUN NMI sleep %i seconds test\n", nmi_sleep);
		run_nmi_sleep_test(nmi_sleep);
	}

	/* If the do_fork test is run it will be the last test that is
	 * executed because a kernel thread will be spawned at the very
	 * end to unregister the debug hooks.
	 */
	if (fork_test) {
		repeat_test = fork_test;
		printk(KERN_INFO "kgdbts:RUN do_fork for %i breakpoints\n",
			repeat_test);
		kthread_run(kgdbts_unreg_thread, NULL, "kgdbts_unreg");
		run_do_fork_test();
		return;
	}

	/* If the sys_open test is run it will be the last test that is
	 * executed because a kernel thread will be spawned at the very
	 * end to unregister the debug hooks.
	 */
	if (do_sys_open_test) {
		repeat_test = do_sys_open_test;
		printk(KERN_INFO "kgdbts:RUN sys_open for %i breakpoints\n",
			repeat_test);
		kthread_run(kgdbts_unreg_thread, NULL, "kgdbts_unreg");
		run_sys_open_test();
		return;
	}
	/* Shutdown and unregister */
	kgdb_unregister_io_module(&kgdbts_io_ops);
	configured = 0;
}