diff options
author | Alec Berg <alecaberg@chromium.org> | 2015-05-01 14:15:31 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-05-02 01:14:13 +0000 |
commit | 7fd9b69239127e41de0686291636b4fc4f72d5d9 (patch) | |
tree | 9a7f38e487919da45d6f2429496c026a316ecc93 /test | |
parent | b2a18a49fecd0081f7ebba00c489d07262ec58d6 (diff) | |
download | chrome-ec-7fd9b69239127e41de0686291636b4fc4f72d5d9.tar.gz |
charge_ramp: fix flaky charge_ramp test
Fix flaky charge_ramp test. The test often delays CHARGE_DETECT_DELAY
after a new charger has been plugged in. But, that is the same delay
the charge_ramp module uses before starting to ramp. This creates a
race condition where sometimes the test resumes before the ramp up
starts and sometimes the test resumes after the ramp up starts. This
change fixes the problem by modifying the test to delay by 100ms
less than the charge_ramp module.
BUG=chromium:483543
BRANCH=none
TEST=run charge_ramp test 10 times w/o this CL and see failure 4
times. run test 20 times with this CL and observe 0 failures.
Change-Id: I5f7a6a05f9293d3dd7db5517a9df7caec95c58ea
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/268798
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/charge_ramp.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/test/charge_ramp.c b/test/charge_ramp.c index 5001c1a664..406888533b 100644 --- a/test/charge_ramp.c +++ b/test/charge_ramp.c @@ -22,9 +22,11 @@ /* * Time to delay for detecting the charger type. This value follows - * the value in common/charge_ramp.c. + * the value in common/charge_ramp.c, but must be less than the real + * CHARGE_DETECT_DELAY so we guarantee we wake up before the ramp + * has started. */ -#define CHARGE_DETECT_DELAY (2*SECOND) +#define CHARGE_DETECT_DELAY_TEST (CHARGE_DETECT_DELAY - 100*MSEC) static int system_load_current_ma; static int vbus_low_current_ma = 500; @@ -97,7 +99,7 @@ static void unplug_charger(void) static int unplug_charger_and_check(void) { unplug_charger(); - usleep(CHARGE_DETECT_DELAY); + usleep(CHARGE_DETECT_DELAY_TEST); return charge_limit_ma == 0; } @@ -118,7 +120,7 @@ static int test_no_ramp(void) system_load_current_ma = 3000; /* A powerful charger, but hey, you're not allowed to ramp! */ plug_charger(CHARGE_SUPPLIER_TEST1, 0, 500, 3000, 3000); - usleep(CHARGE_DETECT_DELAY); + usleep(CHARGE_DETECT_DELAY_TEST); /* That's right. Start at 500 mA */ TEST_ASSERT(charge_limit_ma == 500); TEST_ASSERT(wait_stable_no_overcurrent()); @@ -134,7 +136,7 @@ static int test_full_ramp(void) system_load_current_ma = 3000; /* Now you get to ramp with this 3A charger */ plug_charger(CHARGE_SUPPLIER_TEST4, 0, 500, 3000, 3000); - usleep(CHARGE_DETECT_DELAY); + usleep(CHARGE_DETECT_DELAY_TEST); /* Start with something around 500 mA */ TEST_ASSERT(is_in_range(charge_limit_ma, 500, 800)); TEST_ASSERT(wait_stable_no_overcurrent()); @@ -163,7 +165,7 @@ static int test_overcurrent(void) system_load_current_ma = 3000; /* Huh...VBUS doesn't dip before the charger shuts down */ plug_charger(CHARGE_SUPPLIER_TEST6, 0, 500, 3000, 1500); - usleep(CHARGE_DETECT_DELAY); + usleep(CHARGE_DETECT_DELAY_TEST); /* Ramp starts at 500 mA */ TEST_ASSERT(is_in_range(charge_limit_ma, 500, 700)); @@ -172,7 +174,7 @@ static int test_overcurrent(void) unplug_charger(); usleep(MSEC * 600); plug_charger(CHARGE_SUPPLIER_TEST6, 0, 500, 3000, 1500); - usleep(CHARGE_DETECT_DELAY); + usleep(CHARGE_DETECT_DELAY_TEST); /* Ramp restarts at 500 mA */ TEST_ASSERT(is_in_range(charge_limit_ma, 500, 700)); } @@ -200,7 +202,7 @@ static int test_switch_outlet(void) unplug_charger(); usleep(SECOND * 1.5); plug_charger(CHARGE_SUPPLIER_TEST7, 0, 500, 3000, 3000); - usleep(CHARGE_DETECT_DELAY); + usleep(CHARGE_DETECT_DELAY_TEST); /* Ramp restarts at 500 mA */ TEST_ASSERT(is_in_range(charge_limit_ma, 500, 700)); } @@ -229,7 +231,7 @@ static int test_fast_switch(void) unplug_charger(); usleep(600 * MSEC); plug_charger(CHARGE_SUPPLIER_TEST4, 0, 500, 3000, 3000); - usleep(CHARGE_DETECT_DELAY); + usleep(CHARGE_DETECT_DELAY_TEST); /* Ramp restarts at 500 mA */ TEST_ASSERT(is_in_range(charge_limit_ma, 500, 700)); } @@ -260,7 +262,7 @@ static int test_overcurrent_after_switch_outlet(void) unplug_charger(); usleep(MSEC * 600); plug_charger(CHARGE_SUPPLIER_TEST5, 0, 500, 3000, 1500); - usleep(CHARGE_DETECT_DELAY); + usleep(CHARGE_DETECT_DELAY_TEST); /* Ramp restarts at 500 mA */ TEST_ASSERT(is_in_range(charge_limit_ma, 500, 700)); } @@ -293,7 +295,7 @@ static int test_partial_load(void) unplug_charger(); usleep(MSEC * 600); plug_charger(CHARGE_SUPPLIER_TEST4, 0, 500, 3000, 2500); - usleep(CHARGE_DETECT_DELAY); + usleep(CHARGE_DETECT_DELAY_TEST); /* Ramp restarts at 500 mA */ TEST_ASSERT(is_in_range(charge_limit_ma, 500, 700)); } |