From 8a06a1244c8ee20902db050e142c5a0b2fd777a9 Mon Sep 17 00:00:00 2001 From: Hongjiang Zhang Date: Wed, 7 Jun 2017 13:58:51 +0800 Subject: FreeBSD: fix cdrom mounting failure if /mnt/cdrom/secure did not exist. The current method is to attempt to mount the cdrom (/dev/cd0), if it is successful, /dev/cd0 is configured, otherwise, it is not configured. The problem is it forgets to check whether the mounting destination folder is created or not. As a result, mounting attempt failed even if cdrom is ready. LP: #1696295 --- tests/unittests/test_datasource/test_azure.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'tests/unittests/test_datasource') diff --git a/tests/unittests/test_datasource/test_azure.py b/tests/unittests/test_datasource/test_azure.py index b17f389c..114b1a5d 100644 --- a/tests/unittests/test_datasource/test_azure.py +++ b/tests/unittests/test_datasource/test_azure.py @@ -7,7 +7,8 @@ from cloudinit.util import find_freebsd_part from cloudinit.util import get_path_dev_freebsd from ..helpers import (CiTestCase, TestCase, populate_dir, mock, - ExitStack, PY26, SkipTest) + ExitStack, PY26, PY3, SkipTest) +from mock import patch, mock_open import crypt import os @@ -543,6 +544,15 @@ fdescfs /dev/fd fdescfs rw 0 0 ds.get_data() self.assertEqual(self.instance_id, ds.metadata['instance-id']) + def test_list_possible_azure_ds_devs(self): + devlist = [] + with patch('platform.platform', + mock.MagicMock(return_value="FreeBSD")): + name = 'builtins.open' if PY3 else '__builtin__.open' + with patch(name, mock_open(read_data="data")): + devlist.extend(dsaz.list_possible_azure_ds_devs()) + self.assertEqual(devlist, ['/dev/cd0']) + class TestAzureBounce(TestCase): -- cgit v1.2.3