summaryrefslogtreecommitdiffstats
path: root/sanity/system_light/scripts/multiple_files/multiple_files.sh
blob: 94b859e1cc624d3c8422ec5ac4dd6c75cd18be9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash

# This script creates a directory,creates large number of files in it, lists the contnts of the directory and removes the files

function main ()
{
    mkdir test
    cd test

    echo "start:`date +%T`"
    for i in `seq 1 $NUM_OF_FILES` ; do
        dd if=/dev/zero of=file$i bs=10K count=1 1>/dev/null 2>/dev/null
    done
    echo "end:`date +%T`"

    echo "Creation of $NUM_OF_FILES done"

    TOTAL_FILES=$(ls | wc -l)

    if [ $TOTAL_FILES -ne $NUM_OF_FILES ]; then
        echo "Total files created is not $NUM_OF_FILES"
        err=11
    else
        err=0
    fi

    echo "Removing all the files"

    for i in `seq 1 $NUM_OF_FILES` ; do
        rm file$i
    done

    cd ..
    rmdir test
    if [ $err -ne 0 ]; then
        return $err
    else
        return 0;
    fi
}


main "$@";