Woodstock Blog

a tech blog for general algorithmic interview questions

[Testing] Test Command Line Copy

Question

link

testing the copy command in windows environment

Solution

The most important point is to come up with different domains of inputs and scenarios.

Copying between:

  1. network share
  2. A really slow network share across the Internet
  3. partitions
  4. disks
  5. disks of different types (flash, usb, external sata, SSD, etc…)
  6. directories
  7. within the same directory

Naming

  1. Normal file name
  2. Filename that exceeds 8.3 (verylongfilename.whatever)
  3. Copying a very long file name, but referencing it by it’s 8.3 name (copy verylo~1.wha d:)
  4. A full directory path that exeeds MAX_PATH (260) characters (e.g. c:\a\very\long\directory\name\that\goes\on\forever\in\length……foo.txt)
  5. By absolute addressing (\?\c:\foo\foo.txt)
  6. wildcards (e.g. . *.txt foo?.txt )
  7. A filename with unicode characters
  8. A filename with illegal characters in it (there are creative ways to get these files on disk)

Attributes

  1. Testing with different file attributes (read-only, hidden, system, archive, etc…)
  2. Validate timestamp is preserved across copies
  3. Validate timestamp is preserved across network file share copies when the destination machine is in another timezone
  4. NTFS ACLs are preserved

Addressing types

  1. reference by absolute path (e.g. copy c:\some\directory\foo.txt c:\other\place\foo.txt)
  2. reference by relative path (e.g. copy ....\documents\whatever\foo.txt subdirectory/foo.txt)
  3. By absolute drive letter into current working directoroy of destination (with no path (e.g. copy foo.txt d:)
  4. Network share mounted to a drive letter

Failure cases, edge cases, and hack attacks

  1. Try to copy a file onto itself (e.g copy c:\foo.txt c:\foo.txt)
  2. Copy when the network share is down.
  3. Unplug the network cable in the middle of a network file copy
  4. copy to a read only directory
  5. copy when the source file is locked.
  6. copy the when destination file exists but the destination file exists and is read only
  7. Detach the external disk right before the file copy starts
  8. disk is near full (But would be full before the entire copy finishes)
  9. disk is full
  10. Unplug the power cable in the middle of the copy!
  11. During a very long copy, start another copy with the same source file, but to another destination
  12. During a very long copy, start another copy with a different source file, but the the same destination
  13. During a very long copy, start another copy with the same source and destination files!

File types

  1. ascii file
  2. unicode file
  3. binary file

Environments

  1. RAID configurations
  2. FAT and NTFS
  3. Windows XP, Vista, 7, Server 2003, etc… (you can quantify this by asking the requirement of “which OS” up front)
  4. Virtual Machine (VMWare, virtual PC, hypervisor, etc…)
  5. Intel and AMD