diff options
author | Tomasz Swierczek <t.swierczek@samsung.com> | 2023-02-22 15:22:05 +0100 |
---|---|---|
committer | Tomasz Swierczek <t.swierczek@samsung.com> | 2023-02-23 11:44:26 +0100 |
commit | b043c4f89b7069a98af48f8477ff6ba28bfe7556 (patch) | |
tree | fbdc88b4b42d1b4eb00448ec5953819ef8f5d3cf | |
parent | f6897e7a0bd768b09fb42fd9583121fb38ac816e (diff) | |
download | security-manager-b043c4f89b7069a98af48f8477ff6ba28bfe7556.tar.gz security-manager-b043c4f89b7069a98af48f8477ff6ba28bfe7556.tar.bz2 security-manager-b043c4f89b7069a98af48f8477ff6ba28bfe7556.zip |
Small fixes in unit tests
Spellcheck & another few negative tests for filesystem.
Change-Id: If905479a78f29f341487168483e2b68c13da0ee4
-rw-r--r-- | test/test_filesystem.cpp | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/test/test_filesystem.cpp b/test/test_filesystem.cpp index d080fb7e..2560d200 100644 --- a/test/test_filesystem.cpp +++ b/test/test_filesystem.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. All rights reserved. + * Copyright (c) 2020 - 2023 Samsung Electronics Co., Ltd. All rights reserved. * * This file is licensed under the terms of MIT License or the Apache License * Version 2.0 of your choice. See the LICENSE.MIT file for MIT license details. @@ -138,7 +138,7 @@ POSITIVE_FIXTURE_TEST_CASE(T236_filesystem_mkdir, FilesystemFixture) BOOST_REQUIRE_MESSAGE(FS::createDirectory(FilesystemFixture::subdir1) == SECURITY_MANAGER_SUCCESS, "Error in createDirectory"); BOOST_REQUIRE_MESSAGE(FS::createDirectory(FilesystemFixture::dirToCreateNoParent) == SECURITY_MANAGER_SUCCESS, - "Error in createDIrectory"); + "Error in createDirectory"); } POSITIVE_FIXTURE_TEST_CASE(T237_filesystem_getSubDirectoriesFromDirectory, FilesystemFixture) @@ -193,59 +193,71 @@ NEGATIVE_FIXTURE_TEST_CASE(T243_filesystem_removeDirectory_n, FilesystemFixture) "Wrong return value from removeDirectory"); } -POSITIVE_FIXTURE_TEST_CASE(T244_filesystem_removeFile, FilesystemFixture) +NEGATIVE_FIXTURE_TEST_CASE(T244_filesystem_removeFileAsDirectory_n, FilesystemFixture) +{ + BOOST_REQUIRE_MESSAGE(FS::removeDirectory(FilesystemFixture::textFile) == SECURITY_MANAGER_ERROR_FILE_DELETE_FAILED, + "Wrong return value from removeDirectory"); +} + +POSITIVE_FIXTURE_TEST_CASE(T245_filesystem_removeFile, FilesystemFixture) { BOOST_REQUIRE_MESSAGE(FS::removeFile(FilesystemFixture::fileToRemove) == SECURITY_MANAGER_SUCCESS, "Wrong return value from removeFile"); } -NEGATIVE_FIXTURE_TEST_CASE(T245_filesystem_removeFile_n, FilesystemFixture) +NEGATIVE_FIXTURE_TEST_CASE(T246_filesystem_removeFile_n, FilesystemFixture) { BOOST_REQUIRE_MESSAGE(FS::removeFile(FilesystemFixture::fileCannotRemove) == SECURITY_MANAGER_ERROR_FILE_DELETE_FAILED, "Wrong return value from removeFile"); } -NEGATIVE_FIXTURE_TEST_CASE(T246_filesystem_removeFile, FilesystemFixture) +NEGATIVE_FIXTURE_TEST_CASE(T247_filesystem_removeFile, FilesystemFixture) { BOOST_REQUIRE_MESSAGE(FS::removeFile(FilesystemFixture::nonexistentFile) == SECURITY_MANAGER_ERROR_FILE_DELETE_FAILED, "Wrong return value from removeFile"); } -POSITIVE_FIXTURE_TEST_CASE(T247_filesystem_symlink, FilesystemFixture) +POSITIVE_FIXTURE_TEST_CASE(T248_filesystem_symlink, FilesystemFixture) { BOOST_REQUIRE_MESSAGE(FS::symLink(FilesystemFixture::textFile, FilesystemFixture::linkToCreate) == SECURITY_MANAGER_SUCCESS, "Wrong return value from symLink"); } -NEGATIVE_FIXTURE_TEST_CASE(T248_filesystem_symlink_n, FilesystemFixture) +NEGATIVE_FIXTURE_TEST_CASE(T249_filesystem_symlink_n, FilesystemFixture) { BOOST_REQUIRE_MESSAGE(FS::symLink(FilesystemFixture::textFile, FilesystemFixture::fileToRemove) == SECURITY_MANAGER_ERROR_FILE_CREATE_FAILED, "Wrong return value from symLink"); } -POSITIVE_FIXTURE_TEST_CASE(T249_filesystem_getLinksFromDirectory, FilesystemFixture) +POSITIVE_FIXTURE_TEST_CASE(T250_filesystem_getLinksFromDirectory, FilesystemFixture) { FS::FileNameVector ret = FS::getLinksFromDirectory(FilesystemFixture::dir); BOOST_REQUIRE_MESSAGE(ret.size() == 1, "Invalid number of links returned (" + std::to_string(ret.size()) + ")"); BOOST_REQUIRE_MESSAGE(ret[0] == FilesystemFixture::linkToTextFileName, "Wrong links list (returned " + ret[0]+ ")"); } -NEGATIVE_FIXTURE_TEST_CASE(T250_filesystem_getLinksFromDirectory, FilesystemFixture) +NEGATIVE_FIXTURE_TEST_CASE(T251_filesystem_getLinksFromDirectory_nonexistentDir, FilesystemFixture) { BOOST_REQUIRE_THROW(FS::getLinksFromDirectory(FilesystemFixture::nonexistentDir), FS::Exception::FileError); } -POSITIVE_FIXTURE_TEST_CASE(T251_filesystem_fileStatus_normal_file, FilesystemFixture) + +NEGATIVE_FIXTURE_TEST_CASE(T252_filesystem_getLinksFromDirectory_invalidInput, FilesystemFixture) +{ + BOOST_REQUIRE_THROW(FS::getLinksFromDirectory(FilesystemFixture::textFile), FS::Exception::FileError); +} + +POSITIVE_FIXTURE_TEST_CASE(T253_filesystem_fileStatus_normal_file, FilesystemFixture) { BOOST_REQUIRE_MESSAGE(FS::fileStatus(FilesystemFixture::textFile) == 1, "Wrong file status"); } -POSITIVE_FIXTURE_TEST_CASE(T251_filesystem_fileStatus_nonexistent_file, FilesystemFixture) +POSITIVE_FIXTURE_TEST_CASE(T254_filesystem_fileStatus_nonexistent_file, FilesystemFixture) { BOOST_REQUIRE_MESSAGE(FS::fileStatus(FilesystemFixture::nonexistentFile) == 0, "Wrong file status"); } -NEGATIVE_FIXTURE_TEST_CASE(T252_filesytem_fileStatus_n, FilesystemFixture) +NEGATIVE_FIXTURE_TEST_CASE(T255_filesytem_fileStatus_n, FilesystemFixture) { BOOST_REQUIRE_MESSAGE(FS::fileStatus(FilesystemFixture::dir) == -1, "Wrong file status"); } @@ -255,12 +267,12 @@ POSITIVE_FIXTURE_TEST_CASE(T256_filesystem_directoryStatus_normal_dir, Filesyste BOOST_REQUIRE_MESSAGE(FS::directoryStatus(FilesystemFixture::dir) == 1, "Wrong directory status"); } -POSITIVE_FIXTURE_TEST_CASE(T256_filesystem_directoryStatus_nonexistent_dir, FilesystemFixture) +POSITIVE_FIXTURE_TEST_CASE(T257_filesystem_directoryStatus_nonexistent_dir, FilesystemFixture) { BOOST_REQUIRE_MESSAGE(FS::directoryStatus(FilesystemFixture::nonexistentDir) == 0, "Wrong directory status"); } -NEGATIVE_FIXTURE_TEST_CASE(T257_filesytem_directoryStatus_n, FilesystemFixture) +NEGATIVE_FIXTURE_TEST_CASE(T258_filesytem_directoryStatus_n, FilesystemFixture) { BOOST_REQUIRE_MESSAGE(FS::directoryStatus(FilesystemFixture::textFile) == -1, "Wrong directory status"); } |