Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F7988873
pcmk__full_path_test.c
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
pcmk__full_path_test.c
View Options
/*
* Copyright 2020-2024 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
* This source code is licensed under the GNU General Public License version 2
* or later (GPLv2+) WITHOUT ANY WARRANTY.
*/
#include <crm_internal.h>
#include <crm/common/unittest_internal.h>
#include "mock_private.h"
static void
function_asserts(void **state)
{
pcmk__assert_asserts(pcmk__full_path(NULL, "/dir"));
pcmk__assert_asserts(pcmk__full_path("file", NULL));
}
static void
function_exits(void **state)
{
pcmk__assert_exits(
CRM_EX_OSERR,
{
pcmk__mock_strdup = true; // strdup() will return NULL
expect_string(__wrap_strdup, s, "/full/path");
pcmk__full_path("/full/path", "/dir");
pcmk__mock_strdup = false; // Use real strdup()
}
);
}
static void
full_path(void **state)
{
char *path = NULL;
path = pcmk__full_path("file", "/dir");
assert_int_equal(strcmp(path, "/dir/file"), 0);
free(path);
path = pcmk__full_path("/full/path", "/dir");
assert_int_equal(strcmp(path, "/full/path"), 0);
free(path);
path = pcmk__full_path("../relative/path", "/dir");
assert_int_equal(strcmp(path, "/dir/../relative/path"), 0);
free(path);
}
PCMK__UNIT_TEST(NULL, NULL,
cmocka_unit_test(function_asserts),
cmocka_unit_test(function_exits),
cmocka_unit_test(full_path))
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Sat, Oct 25, 1:59 AM (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2617581
Default Alt Text
pcmk__full_path_test.c (1 KB)
Attached To
Mode
rP Pacemaker
Attached
Detach File
Event Timeline
Log In to Comment