diff --git a/meta/lib/oeqa/selftest/cases/devtool.py b/meta/lib/oeqa/selftest/cases/devtool.py
index b2cd13e9a5..a3c7c293c5 100644
--- a/meta/lib/oeqa/selftest/cases/devtool.py
+++ b/meta/lib/oeqa/selftest/cases/devtool.py
@@ -469,6 +469,38 @@ class DevtoolAddTests(DevtoolBase):
         checkvars['DEPENDS'] = set(['dbus'])
         self._test_recipe_contents(recipefile, checkvars, [])
 
+    def test_devtool_add_git_autorev_finish(self):
+        # Test that a recipe created by devtool add --autorev can be finished
+        # into a layer; this used to fail with "fatal: bad revision 'AUTOINC'"
+        # because the unresolved AUTOREV placeholder was used as the git
+        # revision to export patches from [YOCTO #16354]
+        pn = 'dbus-wait'
+        url = 'git://git.yoctoproject.org/dbus-wait;protocol=https;branch=master'
+        self.track_for_cleanup(self.workspacedir)
+        self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
+        result = runCmd("devtool add --autorev %s '%s'" % (pn, url))
+        recipefile = os.path.join(self.workspacedir, 'recipes', pn, '%s_git.bb' % pn)
+        self.assertExists(recipefile, 'Recipe not created by devtool add')
+        checkvars = {}
+        checkvars['SRCREV'] = '${AUTOREV}'
+        self._test_recipe_contents(recipefile, checkvars, [])
+        # Finish the recipe into a temporary layer
+        templayerdir = tempfile.mkdtemp(prefix='devtoolqa')
+        self.track_for_cleanup(templayerdir)
+        self._create_temp_layer(templayerdir, False, 'selftestautorev')
+        result = runCmd('devtool finish %s %s' % (pn, templayerdir))
+        result = runCmd('devtool status')
+        self.assertNotIn(pn, result.output, 'Recipe should have been reset by finish but wasn\'t')
+        newrecipefiles = glob.glob(os.path.join(templayerdir, 'recipes-*', pn, '%s_git.bb' % pn))
+        self.assertEqual(len(newrecipefiles), 1, 'Recipe not moved into destination layer by devtool finish')
+        # The recipe should still use a floating revision and no patch
+        # files should have been created
+        checkvars = {}
+        checkvars['SRCREV'] = '${AUTOREV}'
+        self._test_recipe_contents(newrecipefiles[0], checkvars, [])
+        patchfiles = glob.glob(os.path.join(templayerdir, 'recipes-*', pn, '*', '*.patch'))
+        self.assertEqual(patchfiles, [], 'Unexpected patch files generated by devtool finish')
+
     def test_devtool_add_git_style1(self):
         version = 'v3.1.0'
         pn = 'mbedtls'
