1f08c3bdfSopenharmony_ci#!/bin/sh
2f08c3bdfSopenharmony_ci#To exectute this you need mongo filesystem utility.
3f08c3bdfSopenharmony_ci#Run this inside the mongo directory.
4f08c3bdfSopenharmony_ci#mongo utility can be found in www.namesys.com/benchmarks/mongo-xxx.tgz
5f08c3bdfSopenharmony_ci#Description-this script tests the mongo utility which actulally give the time ie cpu time
6f08c3bdfSopenharmony_ci#Real time etc on reiserfile system and jfs filesystem.
7f08c3bdfSopenharmony_ci#created by prakash.banu@wipro.com
8f08c3bdfSopenharmony_ci#
9f08c3bdfSopenharmony_ci#   This program is free software;  you can redistribute it and/or modify
10f08c3bdfSopenharmony_ci#   it under the terms of the GNU General Public License as published by
11f08c3bdfSopenharmony_ci#   the Free Software Foundation; either version 2 of the License, or
12f08c3bdfSopenharmony_ci#   (at your option) any later version.
13f08c3bdfSopenharmony_ci#
14f08c3bdfSopenharmony_ci#   This program is distributed in the hope that it will be useful,
15f08c3bdfSopenharmony_ci#   but WITHOUT ANY WARRANTY;  without even the implied warranty of
16f08c3bdfSopenharmony_ci#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
17f08c3bdfSopenharmony_ci#   the GNU General Public License for more details.
18f08c3bdfSopenharmony_ci#
19f08c3bdfSopenharmony_ci#   You should have received a copy of the GNU General Public License
20f08c3bdfSopenharmony_ci#   along with this program;  if not, write to the Free Software
21f08c3bdfSopenharmony_ci#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22f08c3bdfSopenharmony_ci#
23f08c3bdfSopenharmony_ci
24f08c3bdfSopenharmony_ciLOG_DIR=$PWD
25f08c3bdfSopenharmony_ciTEST_DIR=testdir
26f08c3bdfSopenharmony_ci
27f08c3bdfSopenharmony_ci
28f08c3bdfSopenharmony_ci   		#should be root  to execute this script .
29f08c3bdfSopenharmony_ci	if [ $(id -ru) -ne 0 ]; then
30f08c3bdfSopenharmony_ci		echo "This script must be run as root"
31f08c3bdfSopenharmony_ci		exit
32f08c3bdfSopenharmony_ci	fi
33f08c3bdfSopenharmony_ci		#set the PATH variable if its not done .
34f08c3bdfSopenharmony_ciexport PATH=$PATH:/sbin
35f08c3bdfSopenharmony_cilsmod |grep reiserfs
36f08c3bdfSopenharmony_ci
37f08c3bdfSopenharmony_ci	if [ $? -ne 0 ]; then
38f08c3bdfSopenharmony_ci		echo "inserting reiserfs and its dependencies"
39f08c3bdfSopenharmony_ci	fi
40f08c3bdfSopenharmony_cimodprobe reiserfs
41f08c3bdfSopenharmony_ci	if [ $? -ne 0 ]; then
42f08c3bdfSopenharmony_ci		echo "check wheather reiserfs  is been compiled in the kernel"
43f08c3bdfSopenharmony_ci	fi
44f08c3bdfSopenharmony_ci
45f08c3bdfSopenharmony_cilsmod |grep loop
46f08c3bdfSopenharmony_ci	if [ $? -ne 0 ]; then
47f08c3bdfSopenharmony_ci		echo "inserting loopback device module"
48f08c3bdfSopenharmony_ci	fi
49f08c3bdfSopenharmony_cimodprobe loop
50f08c3bdfSopenharmony_ci	if [ $? -ne 0 ]; then
51f08c3bdfSopenharmony_ci		echo "check wheather loopback device option is been compiled in the kernel"
52f08c3bdfSopenharmony_ci	fi
53f08c3bdfSopenharmony_ci
54f08c3bdfSopenharmony_ci	#run the mongo test on reiserfs file system type
55f08c3bdfSopenharmony_cireiserfs()
56f08c3bdfSopenharmony_ci{
57f08c3bdfSopenharmony_cicat > fs.sh <<EOF
58f08c3bdfSopenharmony_ciecho "performing mongo on reiserfs"
59f08c3bdfSopenharmony_cidd if=/dev/zero of=reiserfs  bs=8k count=10240 > /dev/null 2>&1
60f08c3bdfSopenharmony_cilosetup /dev/loop0 reiserfs
61f08c3bdfSopenharmony_cimkdir -p $TEST_DIR
62f08c3bdfSopenharmony_ci./mongo.pl LOG=/tmp/logfile1 file_size=10000 bytes=100000 fstype=reiserfs dev=/dev/loop0 dir=$TEST_DIR RUN   log=$LOG_DIR/reiserlog > /dev/null 2>&1
63f08c3bdfSopenharmony_ci
64f08c3bdfSopenharmony_ciecho "RESULTS LOGGED IN $LOG_DIR/reiserlog"
65f08c3bdfSopenharmony_ciexport PATH=$PATH:/sbin
66f08c3bdfSopenharmony_cilosetup -d /dev/loop0
67f08c3bdfSopenharmony_ci
68f08c3bdfSopenharmony_ciEOF
69f08c3bdfSopenharmony_ci}
70f08c3bdfSopenharmony_ci
71f08c3bdfSopenharmony_ci
72f08c3bdfSopenharmony_ci#To run on jfs file system type
73f08c3bdfSopenharmony_ciJFS()
74f08c3bdfSopenharmony_ci{
75f08c3bdfSopenharmony_cicat >> fs.sh <<EOF
76f08c3bdfSopenharmony_ciecho "performing mongo on jfs file system"
77f08c3bdfSopenharmony_cimkdir -p $TEST_DIR
78f08c3bdfSopenharmony_cidd if=/dev/zero of=jfs  bs=8k count=10240 > /dev/null 2>&1
79f08c3bdfSopenharmony_cilosetup /dev/loop0 jfs
80f08c3bdfSopenharmony_ci./mongo.pl LOG=/tmp/logfile1 file_size=10000 bytes=100000 fstype=jfs dev=/dev/loop0 dir=$TEST_DIR   RUN log=$LOG_DIR/jfslog
81f08c3bdfSopenharmony_ci
82f08c3bdfSopenharmony_ciecho "RESULTS LOGGED IN $LOG_DIR/jfslog"
83f08c3bdfSopenharmony_ciexport PATH=$PATH:/sbin
84f08c3bdfSopenharmony_cilosetup -d /dev/loop0
85f08c3bdfSopenharmony_ciecho "rm -rf ./fs.sh" >> ./fs.sh 2>&1
86f08c3bdfSopenharmony_ciEOF
87f08c3bdfSopenharmony_ci}
88f08c3bdfSopenharmony_ci
89f08c3bdfSopenharmony_ci
90f08c3bdfSopenharmony_ciecho -ne "TEST ON REISERFS?[y/N]:"
91f08c3bdfSopenharmony_ciread ker
92f08c3bdfSopenharmony_ci
93f08c3bdfSopenharmony_cicase $ker in
94f08c3bdfSopenharmony_ciy|Y)     reiserfs
95f08c3bdfSopenharmony_ciesac
96f08c3bdfSopenharmony_ci
97f08c3bdfSopenharmony_ciecho -ne "TEST ON JFS[y/N]: "
98f08c3bdfSopenharmony_ciread ker
99f08c3bdfSopenharmony_ci
100f08c3bdfSopenharmony_cicase $ker in
101f08c3bdfSopenharmony_ciy|Y)     JFS
102f08c3bdfSopenharmony_ciesac
103f08c3bdfSopenharmony_ci
104f08c3bdfSopenharmony_ciecho "THIS MAY TAKE SOME MINUTES"
105f08c3bdfSopenharmony_cish fs.sh
106f08c3bdfSopenharmony_ci
107f08c3bdfSopenharmony_ci#performing cleanup
108f08c3bdfSopenharmony_ci#losetup -d /dev/loop0
109f08c3bdfSopenharmony_cirm -rf $TEST_DIR
110