How to run chromium test

466 views
Skip to first unread message

18f

unread,
Jul 21, 2023, 9:00:19 AM7/21/23
to Chromium-dev
Hey, chromium have many unittest file. I have read some document, like this  Testing in Chromium - Running web tests using the content shell (googlesource.com).

But this  just include blink test. chromium all have another intersting test file. like this pending_beacon_host_unittest.cc - Chromium Code Search. The unitest.cc don't belong blink. and my question is how to run unitest like this? Any suggestion or document will be welcome. Thanks!

PhistucK

unread,
Jul 21, 2023, 9:11:54 AM7/21/23
to 1214...@gmail.com, Chromium-dev

On Fri, Jul 21, 2023 at 2:01 PM 18f <1214...@gmail.com> wrote:
Hey, chromium have many unittest file. I have read some document, like this  Testing in Chromium - Running web tests using the content shell (googlesource.com).

But this  just include blink test. chromium all have another intersting test file. like this pending_beacon_host_unittest.cc - Chromium Code Search. The unitest.cc don't belong blink. and my question is how to run unitest like this? Any suggestion or document will be welcome. Thanks!

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/33914abb-0ef0-4d4f-9ea0-ffe1df207ce0n%40chromium.org.

Fergal Daly

unread,
Jul 21, 2023, 9:14:51 AM7/21/23
to 1214...@gmail.com, Chromium-dev
On Fri, 21 Jul 2023 at 22:00, 18f <1214...@gmail.com> wrote:
Hey, chromium have many unittest file. I have read some document, like this  Testing in Chromium - Running web tests using the content shell (googlesource.com).

But this  just include blink test. chromium all have another intersting test file. like this pending_beacon_host_unittest.cc - Chromium Code Search. The unitest.cc don't belong blink. and my question is how to run unitest like this? Any suggestion or document will be welcome. Thanks!

The hard way (but simple) is to find the BUILD.gn file that references that file. In this case the search leads you here


Then scroll up to find out what test binary it is compiled in. In this case we are lucky and we don't have to scroll up very far. Sometimes, it's hundreds of lines


To find that it's content_unittests. Build and run that to execute the test.

The easy way to do all of that is

$@ gn refs out/Default content/browser/renderer_host/pending_beacon_host_unittest.cc
//content/test:content_unittests

F

Ian Clelland

unread,
Jul 24, 2023, 9:21:58 AM7/24/23
to 1214...@gmail.com, Chromium-dev, fer...@google.com
autotest.py (https://source.chromium.org/chromium/chromium/src/+/main:tools/autotest.py) is even simpler:

tools/autotest.py -C out/Default pending_beacon_host_unittest.cc

will automatically search the BUILD.gn files to find the test binary, and scan the test file itself to determine the names of the tests in it.

You can append additional test filters to target specific tests if you want to as well (sometimes there are a *lot* of tests in a single .cc file, and you really only want to run one or two of them)

18楼梦想改造家

unread,
Oct 8, 2023, 10:09:04 PM10/8/23
to Chromium-dev, Ian Clelland, Chromium-dev, fer...@google.com, 1214...@gmail.com
THX! u are awesome!
Reply all
Reply to author
Forward
0 new messages