Path: blob/main/lib/libc/tests/net/eui64_ntoa_test.c
39534 views
/*1* Copyright 2004 The Aerospace Corporation. All rights reserved.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6*7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions, and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions, and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. The name of The Aerospace Corporation may not be used to endorse or13* promote products derived from this software.14*15* THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "AS IS" AND16* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18* ARE DISCLAIMED. IN NO EVENT SHALL THE AEROSPACE CORPORATION BE LIABLE19* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25* SUCH DAMAGE.26*/2728#include <sys/types.h>29#include <sys/eui64.h>30#include <stdio.h>31#include <string.h>3233#include <atf-c.h>3435#include "test-eui64.h"3637static void38test_str(const char *str, const struct eui64 *eui)39{40char a[EUI64_SIZ];4142ATF_REQUIRE_MSG(eui64_ntoa(&test_eui64_id, a, sizeof(a)) == 0,43"eui64_ntoa failed");44ATF_REQUIRE_MSG(strcmp(a, test_eui64_id_ascii) == 0,45"the strings mismatched: `%s` != `%s`", a, test_eui64_id_ascii);46}4748ATF_TC_WITHOUT_HEAD(id_ascii);49ATF_TC_BODY(id_ascii, tc)50{5152test_str(test_eui64_id_ascii, &test_eui64_id);53}5455ATF_TP_ADD_TCS(tp)56{5758ATF_TP_ADD_TC(tp, id_ascii);5960return (atf_no_error());61}626364