All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] How to compie a ltp-case into 32-bit on the 64bit system
       [not found] <751019010.974973.1438321471218.JavaMail.zimbra@redhat.com>
@ 2015-07-31  6:24 ` Li Wang
  2015-07-31 14:07   ` Li Wang
                     ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Li Wang @ 2015-07-31  6:24 UTC (permalink / raw)
  To: ltp-list

Hi all,

I am going to add a new testcase: ltp/testcases/kernel/syscalls/ipc/msgrcv/msgrcv08.c 
for regression test.

But the key point is that this program 'msgrcv08.c' should be compiled into 32-bit, 
if it is compiled as 64-bit application it doesn't work.


So, I try to add one line in the .../ipc/msgrcv/Makefile:

  msgrcv08: CFLAGS+=-m32

and I get some compile errors like:
-----
# make
make -C ../lib -f "/mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/syscalls/ipc/msgrcv/../lib/Makefile" all
make[1]: Entering directory `/mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/syscalls/ipc/lib'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/syscalls/ipc/lib'
gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -W -g -O2 -Wold-style-definition -m32 -D_FORTIFY_SOURCE=2 -I/mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/include -I/mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/syscalls/ipc/msgrcv/../lib -I../../../../../include -I../../../../../include   -L/mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/syscalls/ipc/msgrcv/../lib -L../../../../../lib  msgrcv08.c   -lltp -lipc -o msgrcv08
/usr/bin/ld: skipping incompatible ../../../../../lib/libltp.a when searching for -lltp
/usr/bin/ld: cannot find -lltp
/usr/bin/ld: skipping incompatible /mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/syscalls/ipc/msgrcv/../lib/libipc.a when searching for -lipc
/usr/bin/ld: cannot find -lipc
collect2: error: ld returned 1 exit status
make: *** [msgrcv08] Error 1
-----

these because the libltp.a is 64-bit.


Then, I came up with a idea that I don't include the ltp-lib file in 'msgrcv08.c', 
and just add two lines in the .../ipc/msgrcv/Makefile:

  msgrcv08:
	gcc -g -O2 -Wall -m32 msgrcv08.c -o msgrcv08

It works for me, but I know it's not appropriate for LTP management.

What should I do? or, Is there any good way to solve this problem?

Thanks~

-- 
Regards, 
Li Wang 
Email: liwang@redhat.com 



------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] How to compie a ltp-case into 32-bit on the 64bit system
  2015-07-31  6:24 ` [LTP] How to compie a ltp-case into 32-bit on the 64bit system Li Wang
@ 2015-07-31 14:07   ` Li Wang
  2015-08-01  1:18   ` Cui Bixuan
  2015-08-03  8:39   ` Cyril Hrubis
  2 siblings, 0 replies; 6+ messages in thread
From: Li Wang @ 2015-07-31 14:07 UTC (permalink / raw)
  To: ltp-list

The program is here.

msgrcv08.c
----------- 
/*
 * Copyright (c) 2015   Author: Gabriellla Schmidt <gsc@bruker.de>
 *                      Modify: Li Wang <liwang@redhat.com>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it would be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * you should have received a copy of the GNU General Public License along
 * with this program; if not, write the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

/*
 * Description:
 *
 * A regression test for:
 * 	commit e7ca2552369c1dfe0216c626baf82c3d83ec36bb
 * 	Author: Mateusz Guzik <mguzik@redhat.com>
 *	Date:   Mon Jan 27 17:07:11 2014 -0800
 *
 *     		ipc: fix compat msgrcv with negative msgtyp
 *
 * Reproduce:
 *
 *	32-bit application using the msgrcv() system call
 *	gives the error message:
 *
 *		msgrcv: No message of desired type
 *
 *	If this progarm is compiled as 64-bit application it doesn't works.
 */

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include "test.h"

const char *TCID = "msgrcv08";
const int TST_TOTAL = 1;

struct msgbuf
{
	long mtype;     /* message type, must be > 0 */
	char mtext[16]; /* message data */
};

static void setup(void)
{
	tst_require_root(NULL);

	TEST_PAUSE;
}

static void cleanup(void)
{
}

static int msr(int msqid)
{
	struct msgbuf msbs;
	struct msgbuf msbr;
	ssize_t sret;
	long   mtype = 121;

	memset(&msbs, 0, sizeof(msbs));
	msbs.mtype = mtype;

	if (msgsnd(msqid, &msbs, sizeof(msbs.mtext), IPC_NOWAIT))
		tst_brkm(TBROK, NULL, "msgsnd error");

	sret = msgrcv(msqid, &msbr, sizeof(msbr.mtext), -mtype, IPC_NOWAIT | MSG_NOERROR);

	if (sret < 0) {
		tst_resm(TFAIL, "Bug: No message of desired type.");
		return -1;
	}

	if (msbr.mtype != mtype)
		tst_brkm(TBROK, NULL, "found mtype %ld, expected %ld\n", msbr.mtype, mtype);

	if ((size_t)sret != sizeof(msbs.mtext))
		tst_brkm(TBROK, NULL, "received %lu, expected %lu\n",
				(unsigned long)sret, (unsigned long)sizeof(msbs.mtext));

	return 0;
}

static void msgrcv_test(void)
{
	int ret;
	int msqid = msgget(IPC_PRIVATE, IPC_CREAT | IPC_EXCL | 0666);

	if (msqid < 0)
		tst_brkm(TBROK, NULL, "msgget error");

	ret = msr(msqid);

	if (msgctl(msqid, IPC_RMID, 0))
		tst_brkm(TBROK, NULL, "msgctl error");

	if (!ret)
		tst_resm(TPASS, "Hi, no regression found!");
}

int main(int argc, char *argv[])
{
	int lc;

	tst_parse_opts(argc, argv, NULL, NULL);

	setup();

	for (lc = 0; TEST_LOOPING(lc); lc++)
		msgrcv_test();

	cleanup();
	tst_exit();
}

-- 
Regards, 
Li Wang 
Email: liwang@redhat.com 


----- Original Message -----
> Hi all,
> 
> I am going to add a new testcase:
> ltp/testcases/kernel/syscalls/ipc/msgrcv/msgrcv08.c
> for regression test.
> 
> But the key point is that this program 'msgrcv08.c' should be compiled into
> 32-bit,
> if it is compiled as 64-bit application it doesn't work.
> 
> 
> So, I try to add one line in the .../ipc/msgrcv/Makefile:
> 
>   msgrcv08: CFLAGS+=-m32
> 
> and I get some compile errors like:
> -----
> # make
> make -C ../lib -f
> "/mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/syscalls/ipc/msgrcv/../lib/Makefile"
> all
> make[1]: Entering directory
> `/mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/syscalls/ipc/lib'
> make[1]: Nothing to be done for `all'.
> make[1]: Leaving directory
> `/mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/syscalls/ipc/lib'
> gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -W -g -O2
> -Wold-style-definition -m32 -D_FORTIFY_SOURCE=2
> -I/mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/include
> -I/mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/syscalls/ipc/msgrcv/../lib
> -I../../../../../include -I../../../../../include
> -L/mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/syscalls/ipc/msgrcv/../lib
> -L../../../../../lib  msgrcv08.c   -lltp -lipc -o msgrcv08
> /usr/bin/ld: skipping incompatible ../../../../../lib/libltp.a when searching
> for -lltp
> /usr/bin/ld: cannot find -lltp
> /usr/bin/ld: skipping incompatible
> /mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/syscalls/ipc/msgrcv/../lib/libipc.a
> when searching for -lipc
> /usr/bin/ld: cannot find -lipc
> collect2: error: ld returned 1 exit status
> make: *** [msgrcv08] Error 1
> -----
> 
> these because the libltp.a is 64-bit.
> 
> 
> Then, I came up with a idea that I don't include the ltp-lib file in
> 'msgrcv08.c',
> and just add two lines in the .../ipc/msgrcv/Makefile:
> 
>   msgrcv08:
> 	gcc -g -O2 -Wall -m32 msgrcv08.c -o msgrcv08
> 
> It works for me, but I know it's not appropriate for LTP management.
> 
> What should I do? or, Is there any good way to solve this problem?
> 
> Thanks~
> 
> --
> Regards,
> Li Wang
> Email: liwang@redhat.com
> 
> 
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
> 

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] How to compie a ltp-case into 32-bit on the 64bit system
  2015-07-31  6:24 ` [LTP] How to compie a ltp-case into 32-bit on the 64bit system Li Wang
  2015-07-31 14:07   ` Li Wang
@ 2015-08-01  1:18   ` Cui Bixuan
  2015-08-03 10:08     ` Li Wang
  2015-08-03  8:39   ` Cyril Hrubis
  2 siblings, 1 reply; 6+ messages in thread
From: Cui Bixuan @ 2015-08-01  1:18 UTC (permalink / raw)
  To: ltp-list

On 2015/7/31 14:24, Li Wang wrote:

> Then, I came up with a idea that I don't include the ltp-lib file in 'msgrcv08.c', 
> and just add two lines in the .../ipc/msgrcv/Makefile:
> 
>   msgrcv08:
> 	gcc -g -O2 -Wall -m32 msgrcv08.c -o msgrcv08
> 
> It works for me, but I know it's not appropriate for LTP management.
> 
> What should I do? or, Is there any good way to solve this problem?
Hi,
    For LTP, we can run './configure CC=[SDK-32]; make;' to compile 32-bit testcases.
So, I think, if the case 'msgrcv08.c' will not work as 64-bit application, it can check the
SDK first. And do 'TCONF: not gcc32' if it's 64-bit application.

    It's not a good idea that ipc/msgrcv/Makefile to control it, I mean, LTP user to control
it in ./configure which will be better.

    What do you think?

Thanks,
Cui Bixuan

> 
> Thanks~
> 


------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] How to compie a ltp-case into 32-bit on the 64bit system
  2015-07-31  6:24 ` [LTP] How to compie a ltp-case into 32-bit on the 64bit system Li Wang
  2015-07-31 14:07   ` Li Wang
  2015-08-01  1:18   ` Cui Bixuan
@ 2015-08-03  8:39   ` Cyril Hrubis
       [not found]     ` <CAEemH2dOo=3Gq=c4eLuYL=itfYHLZMqFMDh_88k7ttUikqLA9Q@mail.gmail.com>
  2 siblings, 1 reply; 6+ messages in thread
From: Cyril Hrubis @ 2015-08-03  8:39 UTC (permalink / raw)
  To: Li Wang; +Cc: ltp-list

Hi!
> # make
> make -C ../lib -f "/mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/syscalls/ipc/msgrcv/../lib/Makefile" all
> make[1]: Entering directory `/mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/syscalls/ipc/lib'
> make[1]: Nothing to be done for `all'.
> make[1]: Leaving directory `/mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/syscalls/ipc/lib'
> gcc -g -O2 -g -O2 -fno-strict-aliasing -pipe -Wall -W -g -O2 -Wold-style-definition -m32 -D_FORTIFY_SOURCE=2 -I/mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/include -I/mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/syscalls/ipc/msgrcv/../lib -I../../../../../include -I../../../../../include   -L/mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/syscalls/ipc/msgrcv/../lib -L../../../../../lib  msgrcv08.c   -lltp -lipc -o msgrcv08
> /usr/bin/ld: skipping incompatible ../../../../../lib/libltp.a when searching for -lltp
> /usr/bin/ld: cannot find -lltp
> /usr/bin/ld: skipping incompatible /mnt/tests/kernel/distribution/ltp/generic/ltp-full-20150420/testcases/kernel/syscalls/ipc/msgrcv/../lib/libipc.a when searching for -lipc
> /usr/bin/ld: cannot find -lipc
> collect2: error: ld returned 1 exit status
> make: *** [msgrcv08] Error 1

That is because the rest of LTP has been compiled for 64 bit and the
linker fails. You have to compile _whole_ LTP with -m32 (pass
CFLAGS=-m32 to configure) so that the tests can be linked with the test
library.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] How to compie a ltp-case into 32-bit on the 64bit system
  2015-08-01  1:18   ` Cui Bixuan
@ 2015-08-03 10:08     ` Li Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Li Wang @ 2015-08-03 10:08 UTC (permalink / raw)
  To: Cui Bixuan; +Cc: ltp-list


[-- Attachment #1.1: Type: text/plain, Size: 1626 bytes --]

Hi,

On Sat, Aug 1, 2015 at 9:18 AM, Cui Bixuan <cuibixuan@huawei.com> wrote:

> On 2015/7/31 14:24, Li Wang wrote:
>
> > Then, I came up with a idea that I don't include the ltp-lib file in
> 'msgrcv08.c',
> > and just add two lines in the .../ipc/msgrcv/Makefile:
> >
> >   msgrcv08:
> >       gcc -g -O2 -Wall -m32 msgrcv08.c -o msgrcv08
> >
> > It works for me, but I know it's not appropriate for LTP management.
> >
> > What should I do? or, Is there any good way to solve this problem?
> Hi,
>     For LTP, we can run './configure CC=[SDK-32]; make;' to compile 32-bit
> testcases.
> So, I think, if the case 'msgrcv08.c' will not work as 64-bit application,
> it can check the
> SDK first. And do 'TCONF: not gcc32' if it's 64-bit application.
>

Thanks for review.  Do u know how to check the SDK first in msgrcv08.c
file?

For me, LTP always running on 64-bit system. So I wanted to run this case
with others(msgrcv0*[1-7}) at the same time. seems like it's very difficult
to achieve.


>
>     It's not a good idea that ipc/msgrcv/Makefile to control it, I mean,
> LTP user to control
> it in ./configure which will be better.
>

>     What do you think?
>

Agree, it's not wise to control the case by Makefile.  and,  it's easy to
get TCONF but hard to get it work.


> Thanks,
> Cui Bixuan
>
> >
> > Thanks~
> >
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
>



-- 
Regards,
Li Wang
Email: liwang@redhat.com

[-- Attachment #1.2: Type: text/html, Size: 2961 bytes --]

[-- Attachment #2: Type: text/plain, Size: 79 bytes --]

------------------------------------------------------------------------------

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [LTP] How to compie a ltp-case into 32-bit on the 64bit system
       [not found]     ` <CAEemH2dOo=3Gq=c4eLuYL=itfYHLZMqFMDh_88k7ttUikqLA9Q@mail.gmail.com>
@ 2015-08-03 11:48       ` Cyril Hrubis
  0 siblings, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2015-08-03 11:48 UTC (permalink / raw)
  To: Li Wang; +Cc: ltp-list

Hi!
> Yes, you are right.
> 
> But I hope to finish the  'msgrcv08' test by LTP automatically. To
> recompile the whole LTP-Lib in 32-bit only for this one case is not my
> expected.  I tend to give up the testcase if we don't have any other  way.
> :(

This is not how this works. You have to compile and run LTP for both
32bit and 64bit to test both 64bit and 32bit versions of syscalls.

So the right solution is to make the test exit with TCONF when compiled
for 64bit.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-08-03 11:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <751019010.974973.1438321471218.JavaMail.zimbra@redhat.com>
2015-07-31  6:24 ` [LTP] How to compie a ltp-case into 32-bit on the 64bit system Li Wang
2015-07-31 14:07   ` Li Wang
2015-08-01  1:18   ` Cui Bixuan
2015-08-03 10:08     ` Li Wang
2015-08-03  8:39   ` Cyril Hrubis
     [not found]     ` <CAEemH2dOo=3Gq=c4eLuYL=itfYHLZMqFMDh_88k7ttUikqLA9Q@mail.gmail.com>
2015-08-03 11:48       ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.