1#!/bin/bash
2# Tests for compare_builds.py
3# usage (from root of source tree):
4#   build/make/tools/exercise_compare_builds
5
6HIDE_BUILD_OUTPUT=--hide-build-output
7
8function run()
9{
10    echo
11    echo
12    echo ============================================================
13    echo $1
14    shift
15    echo ./build/make/tools/compare_builds.py $HIDE_BUILD_OUTPUT --target incidentd $@
16    echo ============================================================
17    time ./build/make/tools/compare_builds.py $HIDE_BUILD_OUTPUT --target incidentd $@
18}
19
20function run_tests()
21{
22    # These should error out
23
24    run "Incremental build,  Separate work dirs  (invalid flag combo, should error out)" \
25        --incremental --detect-embedded-paths
26    run "Use out/ as work dir, Separate work dirs  (invalid flag combo, should error out)" \
27        --no-check-out-dir --detect-embedded-paths
28
29    # Each grouping starts with a build, and the following ones use --no-build to save time
30
31    run "REBUILD: Full builds,  Same work dir,  Whole out dir"
32    run "Full builds,  Same work dir,  Default subdirs" \
33        --no-build --subdirs
34    run "Full builds,  Same work dir,  Only $PRODUCT_OUT/system" \
35        --no-build --subdirs system
36
37    run "REBUILD: Full builds,  Use out/ as work dir,  Whole out dir" \
38        --no-check-out-dir
39    run "Full builds,  Use out/ as work dir,  Default subdirs" \
40        --no-build --no-check-out-dir --subdirs
41    run "Full builds,  Use out/ as work dir,  Only $PRODUCT_OUT/system" \
42        --no-build --no-check-out-dir --subdirs system
43
44    run "REBUILD: Full builds,  Separate work dirs,  Whole out dir" \
45        --detect-embedded-paths
46    run "Full builds,  Separate work dirs,  Default subdirs" \
47        --no-build --detect-embedded-paths --subdirs
48    run "Full builds,  Separate work dirs,  Only $PRODUCT_OUT/system" \
49        --no-build --detect-embedded-paths --subdirs system
50
51    run "REBUILD: Incremental build,  Same work dir,  Whole out dir" \
52        --incremental
53    run "Incremental build,  Same work dir,  Default subdirs" \
54        --no-build --incremental --subdirs
55    run "Incremental build,  Same work dir,  Only $PRODUCT_OUT/system" \
56        --no-build --incremental --subdirs system
57
58    run "REBUILD: Incremental build,  Use out/ as work dir,  Whole out dir" \
59        --incremental --no-check-out-dir
60    run "Incremental build,  Use out/ as work dir,  Default subdirs" \
61        --no-build --incremental --no-check-out-dir --subdirs
62    run "Incremental build,  Use out/ as work dir,  Only $PRODUCT_OUT/system" \
63        --no-build --incremental --no-check-out-dir --subdirs system
64}
65
66time run_tests 2>&1 | tee exercise_compare_builds.txt
67