From e4c405b77bf9b4b031fe2c7615bf99998820b53e Mon Sep 17 00:00:00 2001
From: Peter Barker <pbarker@barker.dropbear.id.au>
Date: Thu, 22 Apr 2021 14:08:29 +1000
Subject: [PATCH] autotest: add a test for Spline missions showing terrain
 requirement

---
 .../autotest/ArduCopter_Tests/SplineTerrain/wp.txt |  6 ++++++
 Tools/autotest/arducopter.py                       | 14 ++++++++++++++
 2 files changed, 20 insertions(+)
 create mode 100644 Tools/autotest/ArduCopter_Tests/SplineTerrain/wp.txt

diff --git a/Tools/autotest/ArduCopter_Tests/SplineTerrain/wp.txt b/Tools/autotest/ArduCopter_Tests/SplineTerrain/wp.txt
new file mode 100644
index 0000000000..ce989b3920
--- /dev/null
+++ b/Tools/autotest/ArduCopter_Tests/SplineTerrain/wp.txt
@@ -0,0 +1,6 @@
+QGC WPL 110
+0	0	0	16	0.000000	0.000000	0.000000	0.000000	-35.363262	149.165237	584.090027	1
+1	0	3	22	0.000000	0.000000	0.000000	0.000000	-35.362991	149.165192	50.000000	1
+2	0	3	82	0.000000	0.000000	0.000000	0.000000	-35.362845	149.165666	50.000000	1
+3	0	3	16	0.000000	0.000000	0.000000	0.000000	-35.363214	149.165905	50.000000	1
+4	0	0	20	0.000000	0.000000	0.000000	0.000000	0.000000	0.000000	0.000000	1
diff --git a/Tools/autotest/arducopter.py b/Tools/autotest/arducopter.py
index 31a5f6e907..3097e1d743 100644
--- a/Tools/autotest/arducopter.py
+++ b/Tools/autotest/arducopter.py
@@ -2725,6 +2725,16 @@ class AutoTestCopter(AutoTest):
         if ex is not None:
             raise ex
 
+    def test_terrain_spline_mission(self):
+        self.set_parameter("AUTO_OPTIONS", 3)
+        self.set_parameter("TERRAIN_ENABLE", 0)
+        self.load_mission("wp.txt")
+        self.change_mode('AUTO')
+        self.wait_ready_to_arm()
+        self.arm_vehicle()
+        self.wait_waypoint(4, 4)
+        self.wait_disarmed()
+
     def test_surface_tracking(self):
         ex = None
         self.context_push()
@@ -6657,6 +6667,10 @@ class AutoTestCopter(AutoTest):
              "Test setpoint global velocity",
              self.test_set_velocity_global_int),
 
+            ("SplineTerrain",
+             "Test Splines and Terrain",
+             self.test_terrain_spline_mission),
+
         ])
         return ret