HALF ECHO LEARN / REFERENCE COLLECTION

v262.2

src/test/test-firstboot-util.c

1,255 bytesGit mode 100644Download original fileLGPL-2.1-or-later

Git blob: bb3c30321f2b13306631adc3b4229831caf4107e

Lines 1–27 of 27

/* SPDX-License-Identifier: LGPL-2.1-or-later */
 
#include "firstboot-util.h"
#include "tests.h"
 
TEST(firstboot_mode_from_string) {
        assert_se(firstboot_mode_from_string("yes") == FIRSTBOOT_INTERACTIVE);
        assert_se(firstboot_mode_from_string("1") == FIRSTBOOT_INTERACTIVE);
        assert_se(firstboot_mode_from_string("on") == FIRSTBOOT_INTERACTIVE);
        assert_se(firstboot_mode_from_string("true") == FIRSTBOOT_INTERACTIVE);
        assert_se(firstboot_mode_from_string("interactive") == FIRSTBOOT_INTERACTIVE);
 
        assert_se(firstboot_mode_from_string("no") == FIRSTBOOT_NO);
        assert_se(firstboot_mode_from_string("0") == FIRSTBOOT_NO);
        assert_se(firstboot_mode_from_string("off") == FIRSTBOOT_NO);
        assert_se(firstboot_mode_from_string("false") == FIRSTBOOT_NO);
 
        assert_se(firstboot_mode_from_string("headless") == FIRSTBOOT_HEADLESS);
 
        assert_se(firstboot_mode_from_string("") == _FIRSTBOOT_MODE_INVALID);
        assert_se(firstboot_mode_from_string(NULL) == _FIRSTBOOT_MODE_INVALID);
        assert_se(firstboot_mode_from_string("Headless") == _FIRSTBOOT_MODE_INVALID);
        assert_se(firstboot_mode_from_string("maybe") == _FIRSTBOOT_MODE_INVALID);
}
 
DEFINE_TEST_MAIN(LOG_INFO);