Skip to content
  • Sascha Silbe's avatar
    5a8fabf3
    qemu-iotests: iotests: fail hard if not run via "check" · 5a8fabf3
    Sascha Silbe authored
    
    
    Running an iotests-based Python test directly might appear to work,
    but may fail in subtle ways and is insecure:
    
    - It creates files with predictable file names in a world-writable
      location (/var/tmp).
    
    - Tests expect the environment to be set up by check. E.g. 041 and 055
      may take the wrong code paths if QEMU_DEFAULT_MACHINE is not
      set. This can lead to false negatives.
    
    Instead fail hard and tell the user we want to be run via "check".
    
    The actual environment expected by the tests is currently only defined
    by the implementation of "check". We use two of the environment
    variables set by "check" as indication of whether we're being run via
    "check". Anyone writing their own test runner (replacing "check") will
    need to replicate the full environment (in a broader sense, not just
    environment variables) provided by "check" anyway, including setting
    the two environment variables we check. Whereas a regular developer
    just trying to invoke the tests usually won't have both of these
    defined in their environment so we can catch their mistake and give
    out useful advice.
    
    Signed-off-by: default avatarSascha Silbe <silbe@linux.vnet.ibm.com>
    Reviewed-by: default avatarBo Tu <tubo@linux.vnet.ibm.com>
    Message-id: 1461094442-16014-1-git-send-email-silbe@linux.vnet.ibm.com
    Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
    5a8fabf3
    qemu-iotests: iotests: fail hard if not run via "check"
    Sascha Silbe authored
    
    
    Running an iotests-based Python test directly might appear to work,
    but may fail in subtle ways and is insecure:
    
    - It creates files with predictable file names in a world-writable
      location (/var/tmp).
    
    - Tests expect the environment to be set up by check. E.g. 041 and 055
      may take the wrong code paths if QEMU_DEFAULT_MACHINE is not
      set. This can lead to false negatives.
    
    Instead fail hard and tell the user we want to be run via "check".
    
    The actual environment expected by the tests is currently only defined
    by the implementation of "check". We use two of the environment
    variables set by "check" as indication of whether we're being run via
    "check". Anyone writing their own test runner (replacing "check") will
    need to replicate the full environment (in a broader sense, not just
    environment variables) provided by "check" anyway, including setting
    the two environment variables we check. Whereas a regular developer
    just trying to invoke the tests usually won't have both of these
    defined in their environment so we can catch their mistake and give
    out useful advice.
    
    Signed-off-by: default avatarSascha Silbe <silbe@linux.vnet.ibm.com>
    Reviewed-by: default avatarBo Tu <tubo@linux.vnet.ibm.com>
    Message-id: 1461094442-16014-1-git-send-email-silbe@linux.vnet.ibm.com
    Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
Loading