xref: /freebsd/tools/test/stress2/misc/ldt2.sh (revision 8a272653)
18a272653SPeter Holm#!/bin/sh
28a272653SPeter Holm
38a272653SPeter Holm#
48a272653SPeter Holm# Copyright (c) 2009 Peter Holm <pho@FreeBSD.org>
58a272653SPeter Holm# All rights reserved.
68a272653SPeter Holm#
78a272653SPeter Holm# Redistribution and use in source and binary forms, with or without
88a272653SPeter Holm# modification, are permitted provided that the following conditions
98a272653SPeter Holm# are met:
108a272653SPeter Holm# 1. Redistributions of source code must retain the above copyright
118a272653SPeter Holm#    notice, this list of conditions and the following disclaimer.
128a272653SPeter Holm# 2. Redistributions in binary form must reproduce the above copyright
138a272653SPeter Holm#    notice, this list of conditions and the following disclaimer in the
148a272653SPeter Holm#    documentation and/or other materials provided with the distribution.
158a272653SPeter Holm#
168a272653SPeter Holm# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
178a272653SPeter Holm# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
188a272653SPeter Holm# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
198a272653SPeter Holm# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
208a272653SPeter Holm# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
218a272653SPeter Holm# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
228a272653SPeter Holm# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
238a272653SPeter Holm# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
248a272653SPeter Holm# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
258a272653SPeter Holm# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
268a272653SPeter Holm# SUCH DAMAGE.
278a272653SPeter Holm#
288a272653SPeter Holm
298a272653SPeter Holm# Test the implementation of i386_get_ldt() and i386_set_ldt() for 32 bit
308a272653SPeter Holm# processes on amd64 by running wine and mplayer with a 32 bit codec.
318a272653SPeter Holm
328a272653SPeter Holm# This is not a test script, but more of a howto document.
338a272653SPeter Holm
348a272653SPeter Holm[ `uname -p` != "amd64" ] && echo "Must run on amd64" && exit
358a272653SPeter Holm
368a272653SPeter Holmexit 0
378a272653SPeter Holm
388a272653SPeter HolmThis are notes of how to perform the test.
398a272653SPeter Holm
408a272653SPeter HolmFirst of all you will need a i386 jail on amd64. This could be build like
418a272653SPeter Holmthis:
428a272653SPeter Holm
438a272653SPeter Holmcat > jailbuild.sh <<EOF
448a272653SPeter Holm#!/bin/sh
458a272653SPeter Holm
468a272653SPeter Holmjail=/var/tmp/jail2 # Change this
478a272653SPeter Holm
488a272653SPeter Holmmount | grep $jail | grep -q devfs && umount $jail/dev
498a272653SPeter Holm
508a272653SPeter Holmhere=`pwd`
518a272653SPeter Holmchflags -R 0 $jail
528a272653SPeter Holmrm -rf $jail
538a272653SPeter Holmmkdir -p $jail
548a272653SPeter Holm
558a272653SPeter Holmcd /var/tmp/deviant2 # You will need to change this!
568a272653SPeter Holmmake -j4 TARGET=i386 TARGET_ARCH=i386 DESTDIR=$jail world
578a272653SPeter Holmmake     TARGET=i386 TARGET_ARCH=i386 DESTDIR=$jail distribution
588a272653SPeter Holm
598a272653SPeter Holmmount -t devfs devfs $jail/dev
608a272653SPeter Holm
618a272653SPeter Holmcp /etc/fstab /etc/hosts /etc/resolv.conf $jail/etc
628a272653SPeter Holmcp /boot/kernel/kernel $jail/boot/kernel
638a272653SPeter HolmEOF
648a272653SPeter Holm
658a272653SPeter HolmBefore changing to the jail you may need these files:
668a272653SPeter Holm- Fetch the Firefox i386 installer. (http://www.mozilla.com)
678a272653SPeter Holm- Fetch a clip for a win32 codec:
688a272653SPeter Holm  ftp http://www.jhepple.com/support/SampleMovies/Real_Media.rm
698a272653SPeter Holm
708a272653SPeter Holmand place these in for examle $jail/root
718a272653SPeter Holm
728a272653SPeter HolmChroot to /var/tmp/jail /bin/sh
738a272653SPeter Holm
748a272653SPeter Holm1) Install wine. For example by "UNAME_m=i386 pkg_add -r wine"
758a272653SPeter Holm3) Run wine on the Firefox installer.
768a272653SPeter Holm
778a272653SPeter HolmThe mplayer test:
788a272653SPeter Holm
798a272653SPeter HolmIt would seem that the default build of mplayer does not contain
808a272653SPeter Holmthe i386 codec, so you have to build mplayer your self with option
818a272653SPeter Holm"Enable win32 codec set on the IA32 arch".
828a272653SPeter HolmRemember to set the environment variable UNAME_m to "i386".
838a272653SPeter Holm
848a272653SPeter Holmcat > mplayer.sh <<EOF
858a272653SPeter Holm#!/bin/sh
868a272653SPeter Holm
878a272653SPeter Holmexport DISPLAY=<your display host goes here>:0
888a272653SPeter Holmwhile true;do
898a272653SPeter Holm	pos=100
908a272653SPeter Holm	for i in `jot 5`; do
918a272653SPeter Holm		mplayer -vc rv40win -geometry $pos:$pos /root/samples/Real_Media.rm < \
928a272653SPeter Holm			/dev/null > /dev/null 2>&1 &
938a272653SPeter Holm		pos=$((pos + 50))
948a272653SPeter Holm	done
958a272653SPeter Holm	for i in `jot 5`; do
968a272653SPeter Holm		wait
978a272653SPeter Holm	done
988a272653SPeter Holmdone
998a272653SPeter HolmEOF
100