0
Commit Graph

19 Commits

Author SHA1 Message Date
Dan Harrington
8e95b897b5 autotest: stop if build fails
Sometimes, autotest will run the test even though the
build fails. This occurs when a gn file is modified
before running autotest.py.

This change ensures that the test is not run when
the build fails.

Change-Id: I6ed35e83f02ee59697030c466c500202aa8536f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2898147
Auto-Submit: Dan H <harringtond@chromium.org>
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#883121}
2021-05-14 21:02:10 +00:00
Dan Harrington
379029cbbe autotest: add wpr_tests to regex
Allows autotest to work for wpr tests.

Change-Id: I2ec3187df85c076e614dfebc40f54d32b665b321
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2894691
Auto-Submit: Dan H <harringtond@chromium.org>
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#882710}
2021-05-13 21:54:56 +00:00
Olivier Li
8ac87f419d Add option to autotest.py to not use Android test wrappers.
Change-Id: Ifefece0df82f8c23c805cd8ea8c3a55ec8b3c610
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2870306
Commit-Queue: Olivier Li <olivierli@chromium.org>
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#879361}
2021-05-05 15:26:54 +00:00
Michael Thiessen
f2c56823b4 Implement Attribution intent validation
Implements the intent sender validation, and satisfies the module's API
contract. Follwup changes will make use of the data the sender sends.
Also, this code isn't hooked up to the LaunchIntentDispatcher yet, that
will come in a followup.

I've chosen to use a MAC on the intent to validate the creator of the
intent sent by the received PendingIntent in order to avoid
complexities around static state. Replay attacks etc. aren't really a
concern as only the original PendingIntent sender could replay the
Intent - but they don't gain anything from being able to replay
messages as they can already just send anything they want. Future CLs
will implement things like rate-limiting, input validation, etc. to
help avoid abuse of this API.

Explainer:
https://github.com/WICG/conversion-measurement-api/blob/main/app_to_web.md

Bug: 1198308
Change-Id: I6f1e9eb079f41b27cdb9e4ee85b2f22c2266d813
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2860466
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Reviewed-by: Charlie Harrison <csharrison@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#879004}
2021-05-04 19:47:33 +00:00
Michael Thiessen
b7f3eaa65b Fix autotest.py running tests even when the build fails
When targets change and the build fails, autotest.py failed to exit, and
ended up running the tests anyways.

Change-Id: Ied41ffc6376923b4765fba7e8bff94450598b62c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2860402
Auto-Submit: Michael Thiessen <mthiesse@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#877540}
2021-04-29 17:47:18 +00:00
Peter Wen
1b84b4b13e Android: Automatic out-dir detection for autotest
Use automatic out-dir detection based on environment variables and build
type.

Also use / instead of join and minor cleanups.

Bug: None
Change-Id: I7c29063d62405e5bd6500390607b8a625ac2d4a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2747688
Auto-Submit: Peter Wen <wnwen@chromium.org>
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Commit-Queue: Peter Wen <wnwen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#862043}
2021-03-11 18:12:22 +00:00
Andrew Grieve
c2122d27d5 Make autotest.py recognize chrome_public_test_vr_apk
The suffix is _test_vr_apk rather than _test_apk, so it wasn't being
identified as a test.

Bug: None
Change-Id: Idb4e8eb7bb4efd9625940d3ea28c664e4f98c50c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2687655
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#852661}
2021-02-10 16:22:29 +00:00
Mario Bianucci
6b5450075b Allow autotest to collect tests that don't include gtest files
Autotest checks for gtest files to better determine if a give file is
actually a test file or not. However, because many files don't actually
include what they use, many test files don't directly include gtest.h,
gmock.h, or a test_utils.h file. Instead, they may include those via
something like sim_test.h, resulting in the script ignoring those files
right now.

This change improves that by still looking for files that include a
gtest file, but until it has found at least one file that does, it
will also collect files that match the test file name regex and do not
match the gtest include regex. Then, if no files are found with the
gtest includes, it will move forward under the assumption that the
file it found without the gtest include was the correct test file.

It will still prefer files with gtest includes, but has a fallback in
case none exist, providing a best effort chance at building and
running the tests.

Also includes a small improvement to outputting the file names that
it finds after a recursive file search.

Change-Id: Ia56792426b55cb17a43ffe2545b4deefb5dba0dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2568710
Commit-Queue: Mario Bianucci <mabian@microsoft.com>
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832607}
2020-12-02 01:33:39 +00:00
Michael Thiessen
a8a82f5c65 Fix autotest dry run
Fixes autotest dry run to print both the build and test run command,
instead of just the build command.

Change-Id: I8bbccacb2e8360f3a9066c4a02de5867d79542b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2565590
Auto-Submit: Michael Thiessen <mthiesse@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#831895}
2020-11-30 18:05:32 +00:00
Mario Bianucci
ebea79d708 Improvements to autotest.py
This CL includes several improvements to autotest.py:
-Slightly expand the GTest regex.
  -Previously, it missed some tests due to them not explicitly including
    gtest via #include "...gtest.h". Variations included <...gtest.h>,
    gmock.h, or via *test_utils.h. Expand the regex to include these
    cases.
  -In my (limited) testing I didn't see any large regressions in terms
    of number of files added via the expanded regex, but its possible
    there is something I missed.
-Add utf-8 encoding when opening a file to read.
  -This avoids errors when opening files with non-English characters.
-Debugging lines to output all files that matched the regex.
-Added sys.executable to beginning of call to make-gtest-filter.py.
  -This enables it to work on Windows, which requires 'python3' before
    calling a python script.

Change-Id: Ic9e67658b7298867d997ba4cc396320bf5d61c8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2517944
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Commit-Queue: Mario Bianucci <mabian@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#824031}
2020-11-04 17:19:00 +00:00
Andrew Grieve
a5193d3a54 autotest.py: Use autoninja from PATH. Make -C optional
Use autoninja from PATH so that it matches the version used when
building explicitly (allows for devs that are using a custom-built
version of ninja).

Allow omitting -C when script is run from within the output directory.
This matches ninja's behavior.

Bug: None
Change-Id: I55763f178e2cf85892efbb4397a7ec81ed054aa5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2419608
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808875}
2020-09-21 14:58:34 +00:00
Michael Thiessen
7bbda48e1f Make autotest java test filter more robust
Fix autotest so autotest.py -C <dir> /CurrentPageVerifierTest.java won't
run tests for other classes like WebApkCurrentPageVerifierTest

Change-Id: I0370b507ac21009676d9e27c109b90d7223b7ab9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2419267
Auto-Submit: Michael Thiessen <mthiesse@chromium.org>
Commit-Queue: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808645}
2020-09-19 02:07:34 +00:00
Dan Harrington
aa2c7ba1e9 A few autotest improvements
* > autotest ... base/strings/strcat.cc
  will now run tests for base/strings/strcat_unittest.cc

* > autotest ... strcat
  no longer complains "strcat" is ambiguous, since strcat_unittest.cc is
  the only matching test file.

* Fixed rare case where caching could use the wrong
  target.

Change-Id: Id028b8d5477687bef02b6cd94688f74839d08964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2407857
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Commit-Queue: Dan H <harringtond@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807479}
2020-09-16 15:34:24 +00:00
Dan Harrington
27d104dac2 Improvements to autotest.py
- Use make-gtest-filter.py to build a gtest filter automatically.
- Allow testing a full directory.
- --run-all: allow testing multiple targets in one run, instead of
  asking the user to pick.
- Speed it up if a file path is specified, by skipping the file
  search.
- Cache gn refs output, to make follow-up runs faster.
- Add --line option, to run a test at specific line number.
- Change call to ninja build so that output is streamed
- Switch to printing errors end then exiting for non-exceptional errors.
  This makes user errors more readable.

Change-Id: Ib3660123f5a7fe5c3ef3369d360c3ea3218d233a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2391209
Commit-Queue: Dan H <harringtond@chromium.org>
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804987}
2020-09-08 18:30:14 +00:00
Jesse McKenna
83b6ac1b8a Make autotest.py support forward slash on Windows
Currently, autotest.py doesn't support the forward slash '/' as a path
separator on Windows. For example:

Succeeds:
python3 tools/autotest.py -C out/bug base\at_exit_unittest
--gtest_filter=*Exit*

Fails:
python3 tools/autotest.py -C out/bug base/at_exit_unittest
--gtest_filter=*Exit*

This is because RecursiveMatchFilename() considers a file a match with
the requested filename if the requested filename is a substring of the
file's full path. On Windows, file paths as returned by os.scandir()
use '\\' as a path separator, so a path using '/' will never match
(e.g. 'base/at_exit_unittest' is not a substring of
'C:\\src\\chromium\\src\\base\\at_exit_unittest.cc').

With this change, either type of path separator works on Windows.

Change-Id: Ic21eff291d86e7ca994faeda807f6aeaff737562
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2181744
Commit-Queue: Jesse McKenna <jessemckenna@google.com>
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#766500}
2020-05-07 18:25:38 +00:00
Michael Thiessen
0264afc6c7 Ignore vim swap files in autotest.py
Change-Id: Iac30106a597ade4a6a7826bf5ed9890c94a1514f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135423
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756398}
2020-04-03 20:31:34 +00:00
K. Moon
01548667da Fix autotest.py's platform check on macOS
tools/autotest.py currently uses `"win" in sys.platform` to detect if
the current platform is Windows. macOS uses "darwin" as the platform, so
this check erroneously detects macOS as Windows.

According to the documentation for sys.platform, the platform value
should be matched against sys.platform as a prefix:
https://docs.python.org/3/library/sys.html#sys.platform

This change tightens the check to only detect platforms starting with
"win32" as Windows.

R=mthiesse

Change-Id: Ic46cbc3b28c250d6557a58f583d5a9ba03df5b6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134964
Auto-Submit: K Moon <kmoon@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Reviewed-by: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756079}
2020-04-03 00:14:25 +00:00
Michael Thiessen
f46171eb76 Support //chrome/test:unit_tests in autotest.py
Bug: 1066521
Change-Id: Ib591b5ee471f4bc55a8fbbec2a1cd0b4762e1b60
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2129990
Reviewed-by: Brandon Wylie <wylieb@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754994}
2020-03-31 17:29:38 +00:00
Michael Thiessen
09c0e1d0b7 Introduce script to build and run a test file by name.
Uses gn refs to find the test target containing the file, then builds
and runs the suite. For java test files the filter can be automatically
generated, but for c++ it isn't as straightforward so I've made the
filter mandatory.

./tools/autotest.py -C out/Desktop image_decoder_browsertest.cc --gtest_filter="ImageDecoder"
./tools/autotest.py -C out/Android UrlUtilitiesUnitTest --fast-local-dev -v

Examples: 
Change-Id: I1840ef3634e4a011f871acd973d5f8bb5038c3a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2101542
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#752515}
2020-03-23 18:44:50 +00:00