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""" 8This testcase exercises the filesystem by creating files of a specified size 9and verifying the files are actually created to specification. This test will 10ensure we can create a 1gb size file on the stateful partition, and a 100mb 11size file on the /tmp partition. 12""" 13 14__author__ = 'kdlucas@chromium.org (Kelly Lucas)' 15 16import os 17import sys 18 19from autotest_lib.client.bin import utils, test 20from autotest_lib.client.common_lib import error 21 22 23class 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