• Maciej Wieczor-Retman's avatar
    selftests/resctrl: Fix schemata write error check · 20d96b25
    Maciej Wieczor-Retman authored
    Writing bitmasks to the schemata can fail when the bitmask doesn't
    adhere to constraints defined by what a particular CPU supports.
    Some example of constraints are max length or having contiguous bits.
    The driver should properly return errors when any rule concerning
    bitmask format is broken.
    
    Resctrl FS returns error codes from fprintf() only when fclose() is
    called. Current error checking scheme allows invalid bitmasks to be
    written into schemata file and the selftest doesn't notice because the
    fclose() error code isn't checked.
    
    Substitute fopen(), flose() and fprintf() with open(), close() and
    write() to avoid error code buffering between fprintf() and fclose().
    
    Remove newline character from the schema string after writing it to
    the schemata file so it prints correctly before function return.
    
    Pass the string generated with strerror() to the "reason" buffer so
    the error message is more verbose. Extend "reason" buffer so it can hold
    longer messages.
    Signed-off-by: default avatarMaciej Wieczor-Retman <maciej.wieczor-retman@intel.com>
    Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
    Reviewed-by: default avatarReinette Chatre <reinette.chatre@intel.com>
    Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
    20d96b25
resctrlfs.c 15.7 KB