#!/bin/bash

# Copyright (c) 2021-2026 Red Hat.
#
# This is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3, or (at your
# option) any later version.
#
# It is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# Mimics how glibc builds C sources without annotation.

TEST_NAME=unicode
. $srcdir/common.sh

start_test

$GCC $srcdir/trick-hello.s -o trick-hello.exe > $G_OUT 2>&1

if [ $? != 0 ];
then
    echo "$TEST_NAME: SKIP: Could not assemble test source file"
    cat $G_OUT
    end_test
    exit $EXIT_TEST_SKIPPED
fi

# Run annocheck

OPTS="--skip-all --ignore-gaps --test-unicode --test-unicode-suspicious  --suppress-version-warnings"

$ANNOCHECK trick-hello.exe $OPTS > $A_OUT
grep -q -e"FAIL: unicode" $A_OUT
if [ $? != 0 ];
then
    echo "$TEST_NAME: FAIL: annocheck did not detect suspicious symbol names"
    cat $A_OUT
    end_test
    exit $EXIT_TEST_FAILED
fi

echo "$TEST_NAME: PASS: annocheck detected suspicious symbol names"

end_test
