1 #!/usr/bin/python 2 # 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 4 # Use of this source code is governed by a BSD-style license that can be 5 # found in the LICENSE file. 6 7 """ 8 This testcase exercises the filesystem by creating files of a specified size 9 and verifying the files are actually created to specification. This test will 10 ensure we can create a 1gb size file on the stateful partition, and a 100mb 11 size file on the /tmp partition. 12 """ 13 14 __author__ = 'kdlucas (at] chromium.org (Kelly Lucas)' 15 16 import os 17 import sys 18 19 from autotest_lib.client.bin import utils, test 20 from autotest_lib.client.common_lib import error 21 22 23 class platform_FileSize(test.test): 24 """Test creating large files on various file systems.""" 25 version = 1 26 27 def create_file(self, size, fname): 28 """ 29 Create a file with the specified size. 30 31 Args: 32 size: int, size in megabytes 33 fname: string, filename to create 34 Returns: 35 int, size of file created. 36 """ 37 TEXT = 'ChromeOS knows how to make your netbook run fast!\n' 38 count = size * 20000 39 fh = file(fname, 'w') 40 for i in range(count): 41 fh.write(TEXT) 42 fh.close() 43 44 if os.path.exists(fname): 45 fsize = os.path.getsize(fname) 46 os.remove(fname) 47 return fsize 48 raise error.TestFail('Error, %s not found' % fname) 49 50 def run_once(self): 51 reqsize = [1024, 100] 52 reqname = ['/mnt/stateful_partition/tempfile', '/tmp/tempfile'] 53 m = 1000000 54 55 for i in range(2): 56 filesize = self.create_file(reqsize[i], reqname[i]) 57 if not (filesize == (reqsize[i] * m)): 58 raise error.TestFail('%s file test failed.' % reqname[i]) 59