summaryrefslogtreecommitdiff
path: root/test/debug.c
blob: 2c637ab725985dccc9227cc4c2e944e7d42c47ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* Copyright 2022 The ChromiumOS Authors
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#include "common.h"
#include "debug.h"
#include "string.h"
#include "test_util.h"

static bool debugger_connected;

static void print_usage(void)
{
	ccprintf("usage: runtest [debugger|no_debugger]\n");
}

test_static int test_debugger_is_connected(void)
{
	ccprintf("debugger_is_connected: %d\n", debugger_connected);
	TEST_EQ(debugger_is_connected(), debugger_connected, "%d");
	return EC_SUCCESS;
}

void run_test(int argc, const char **argv)
{
	test_reset();

	if (argc < 2) {
		print_usage();
		test_fail();
		return;
	}

	if (strncmp(argv[1], "debugger", sizeof("debugger")) == 0)
		debugger_connected = true;
	else if (strncmp(argv[1], "no_debugger", sizeof("no_debugger")) == 0) {
		debugger_connected = false;
	} else {
		print_usage();
		test_fail();
		return;
	}

	RUN_TEST(test_debugger_is_connected);
	test_print_result();
}