summaryrefslogtreecommitdiff
path: root/test/mag_cal.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2021-11-04 12:11:58 -0600
committerCommit Bot <commit-bot@chromium.org>2021-11-05 04:22:34 +0000
commit252457d4b21f46889eebad61d4c0a65331919cec (patch)
tree01856c4d31d710b20e85a74c8d7b5836e35c3b98 /test/mag_cal.c
parent08f5a1e6fc2c9467230444ac9b582dcf4d9f0068 (diff)
downloadchrome-ec-stabilize-14682.B-ish.tar.gz
In the interest of making long-term branch maintenance incur as little technical debt on us as possible, we should not maintain any files on the branch we are not actually using. This has the added effect of making it extremely clear when merging CLs from the main branch when changes have the possibility to affect us. The follow-on CL adds a convenience script to actually pull updates from the main branch and generate a CL for the update. BUG=b:204206272 BRANCH=ish TEST=make BOARD=arcada_ish && make BOARD=drallion_ish Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I17e4694c38219b5a0823e0a3e55a28d1348f4b18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3262038 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'test/mag_cal.c')
-rw-r--r--test/mag_cal.c91
1 files changed, 0 insertions, 91 deletions
diff --git a/test/mag_cal.c b/test/mag_cal.c
deleted file mode 100644
index 8ee3b41480..0000000000
--- a/test/mag_cal.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "common.h"
-#include "mag_cal.h"
-#include "test_util.h"
-#include <stdio.h>
-
-/**
- * Various samples that might be seen in the wild. Normal range for magnetic
- * fields is around 80 uT. This translates to roughly +/-525 units for the
- * lis2mdl sensor.
- *
- * Random numbers were generated using the range of [518,532] (+- 2.14 uT) for
- * the high values and [-5,5] (+- 1.53 uT) for the low values.
- */
-static intv3_t samples[] = {
- { -522, 5, -5 },
- { -528, -3, 1 },
- { -531, -2, 0 },
- { -525, -1, 3 },
-
- { 527, 3, -2 },
- { 523, -5, 1 },
- { 520, -3, 2 },
- { 522, 0, -4 },
-
- { -3, -519, -2 },
- { 1, -521, 5 },
- { 2, -526, 4 },
- { 0, -532, -5 },
-
- { -5, 528, 4 },
- { -2, 531, -4 },
- { 1, 522, 2 },
- { 5, 532, 3 },
-
- { -5, 0, -524 },
- { -1, -2, -527 },
- { -3, 4, -532 },
- { 5, 3, -531 },
-
- { 4, -2, 524 },
- { 1, 3, 520 },
- { 5, -5, 528 },
- { 0, 2, 521 },
-};
-
-static int test_mag_cal_computes_bias(void)
-{
- struct mag_cal_t cal;
- int i;
-
- init_mag_cal(&cal);
- cal.batch_size = ARRAY_SIZE(samples);
-
- /* Test that we don't calibrate until we added the final sample. */
- for (i = 0; i < cal.batch_size - 1; ++i)
- TEST_EQ(0, mag_cal_update(&cal, samples[i]), "%d");
- /* Add the final sample and check calibration. */
- TEST_EQ(1, mag_cal_update(&cal, samples[cal.batch_size - 1]), "%d");
- TEST_EQ(525, FP_TO_INT(cal.radius), "%d");
- TEST_EQ(1, cal.bias[0], "%d");
- TEST_EQ(-1, cal.bias[1], "%d");
- TEST_EQ(2, cal.bias[2], "%d");
-
- /*
- * State should have reset, run the same code again to verify that
- * we get the same calibration.
- */
- for (i = 0; i < cal.batch_size - 1; ++i)
- TEST_EQ(0, mag_cal_update(&cal, samples[i]), "%d");
- TEST_EQ(1, mag_cal_update(&cal, samples[cal.batch_size - 1]), "%d");
- TEST_EQ(525, FP_TO_INT(cal.radius), "%d");
- TEST_EQ(1, cal.bias[0], "%d");
- TEST_EQ(-1, cal.bias[1], "%d");
- TEST_EQ(2, cal.bias[2], "%d");
-
- return EC_SUCCESS;
-}
-
-void run_test(int argc, char **argv)
-{
- test_reset();
-
- RUN_TEST(test_mag_cal_computes_bias);
-
- test_print_result();
-}