Loading...
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | # SPDX-License-Identifier: GPL-2.0+ # Copyright (c) 2019, Texas Instrument # Author: Jean-Jacques Hiblot <jjhiblot@ti.com> # # U-Boot File System:symlink Test """ This test verifies unlink operation (deleting a file or a directory) on file system. """ import pytest import re from fstest_defs import * from fstest_helpers import assert_fs_integrity @pytest.mark.boardspec('sandbox') @pytest.mark.slow class TestSymlink(object): def test_symlink1(self, ubman, fs_obj_symlink): """ Test Case 1 - create a link. and follow it when reading """ fs_type, fs_img, md5val = fs_obj_symlink with ubman.log.section('Test Case 1 - create link and read'): output = ubman.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'ln host 0:0 %s /%s.link ' % (SMALL_FILE, SMALL_FILE), ]) assert('' in ''.join(output)) output = ubman.run_command_list([ '%sload host 0:0 %x /%s.link' % (fs_type, ADDR, SMALL_FILE), 'printenv filesize']) assert('filesize=100000' in ''.join(output)) # Test Case 4b - Read full 1MB of small file output = ubman.run_command_list([ 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val[0] in ''.join(output)) assert_fs_integrity(fs_type, fs_img) def test_symlink2(self, ubman, fs_obj_symlink): """ Test Case 2 - create chained links """ fs_type, fs_img, md5val = fs_obj_symlink with ubman.log.section('Test Case 2 - create chained links'): output = ubman.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'ln host 0:0 %s /%s.link1 ' % (SMALL_FILE, SMALL_FILE), 'ln host 0:0 /%s.link1 /SUBDIR/%s.link2' % ( SMALL_FILE, SMALL_FILE), 'ln host 0:0 SUBDIR/%s.link2 /%s.link3' % ( SMALL_FILE, SMALL_FILE), ]) assert('' in ''.join(output)) output = ubman.run_command_list([ '%sload host 0:0 %x /%s.link3' % (fs_type, ADDR, SMALL_FILE), 'printenv filesize']) assert('filesize=100000' in ''.join(output)) # Test Case 4b - Read full 1MB of small file output = ubman.run_command_list([ 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val[0] in ''.join(output)) assert_fs_integrity(fs_type, fs_img) def test_symlink3(self, ubman, fs_obj_symlink): """ Test Case 3 - replace file/link with link """ fs_type, fs_img, md5val = fs_obj_symlink with ubman.log.section('Test Case 1 - create link and read'): output = ubman.run_command_list([ 'host bind 0 %s' % fs_img, 'setenv filesize', 'ln host 0:0 %s /%s ' % (MEDIUM_FILE, SMALL_FILE), 'ln host 0:0 %s /%s.link ' % (MEDIUM_FILE, MEDIUM_FILE), ]) assert('' in ''.join(output)) output = ubman.run_command_list([ '%sload host 0:0 %x /%s' % (fs_type, ADDR, SMALL_FILE), 'printenv filesize']) assert('filesize=a00000' in ''.join(output)) output = ubman.run_command_list([ 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val[1] in ''.join(output)) output = ubman.run_command_list([ 'ln host 0:0 %s.link /%s ' % (MEDIUM_FILE, SMALL_FILE), '%sload host 0:0 %x /%s' % (fs_type, ADDR, SMALL_FILE), 'printenv filesize']) assert('filesize=a00000' in ''.join(output)) output = ubman.run_command_list([ 'md5sum %x $filesize' % ADDR, 'setenv filesize']) assert(md5val[1] in ''.join(output)) assert_fs_integrity(fs_type, fs_img) def test_symlink4(self, ubman, fs_obj_symlink): """ Test Case 4 - create a broken link """ fs_type, fs_img, md5val = fs_obj_symlink with ubman.log.section('Test Case 1 - create link and read'): output = ubman.run_command_list([ 'setenv filesize', 'ln host 0:0 nowhere /link ', ]) assert('' in ''.join(output)) output = ubman.run_command( '%sload host 0:0 %x /link' % (fs_type, ADDR)) with ubman.disable_check('error_notification'): output = ubman.run_command('printenv filesize') assert('"filesize" not defined' in ''.join(output)) assert_fs_integrity(fs_type, fs_img) |