Bug 13686

Summary: testsuite: hostname-i-works failed unexpectedly if there are multiple IP address
Product: Busybox Reporter: Shuang Qiu <shuang.qiu>
Component: OtherAssignee: unassigned
Status: NEW ---    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:
Attachments: patch to fix the issue

Description Shuang Qiu 2021-03-31 09:09:13 UTC
On a linux system which has multiple IP address,i.e.:
# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether a0:49:fb:04:98:2e brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.167/24 brd 192.168.122.255 scope global eth0
       valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:32:20:ee:26 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever

Steps to reproduce:
1. cd testsuite directory
2. ./runtest -v hostname

PASS: hostname-d-works
FAIL: hostname-i-works
+ test x '!=' x
++ hostname -i
++ xargs
++ busybox hostname -i
+ test x192.168.122.167 172.17.0.1 = x192.168.122.167 172.17.0.1
/usr/lib64/busybox/ptest/testsuite/hostname/hostname-i-works: line 9: test: too many arguments
PASS: hostname-s-works
PASS: hostname-works
Comment 1 Shuang Qiu 2021-03-31 09:19:01 UTC
Created attachment 8846 [details]
patch to fix the issue

It is because testsuite/hostname/hostname-i-works script does not handle writespace for the arguments of test command,add double quote to the arguments are fix the issue.

Tested with the patch:
./runtest -v hostname
PASS: hostname-d-works
PASS: hostname-i-works
PASS: hostname-s-works
PASS: hostname-works