Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

unittests: test_tokenizer: better handle mismatch error

The current logic is too sensitive to how c_lex name is
placed. Also, it doesn't really check the log.

Change it to check if the expected message will be reported
after a call to C tokenizer with an invalid source.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <6e19578bc1ffa96e536dc31997ff658017f60173.1773823995.git.mchehab+huawei@kernel.org>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
14b7775e 781171be

+10 -3
+10 -3
tools/unittests/test_tokenizer.py
··· 46 46 # 47 47 # Check if logger is working 48 48 # 49 - if "log_level" in data: 50 - with self.assertLogs('kdoc.c_lex', level='ERROR') as cm: 49 + if "log_msg" in data: 50 + with self.assertLogs() as cm: 51 51 tokenizer = CTokenizer(data["source"]) 52 + 53 + msg_found = False 54 + for result in cm.output: 55 + if data["log_msg"] in result: 56 + msg_found = True 57 + 58 + self.assertTrue(msg_found, f"Missing log {data['log_msg']}") 52 59 53 60 return 54 61 ··· 131 124 132 125 "mismatch_error": { 133 126 "source": "int a$ = 5;", # $ is illegal 134 - "log_level": "ERROR", 127 + "log_msg": "Unexpected token", 135 128 }, 136 129 } 137 130