Home | History | Annotate | Download | only in kernel
      1 // Copyright 2014 The Android Open Source Project
      2 //
      3 // This software is licensed under the terms of the GNU General Public
      4 // License version 2, as published by the Free Software Foundation, and
      5 // may be copied, distributed, and modified under those terms.
      6 //
      7 // This program is distributed in the hope that it will be useful,
      8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
      9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     10 // GNU General Public License for more details.
     11 
     12 #ifndef ANDROID_KERNEL_KERNEL_UTILS_TESTING_H
     13 #define ANDROID_KERNEL_KERNEL_UTILS_TESTING_H
     14 
     15 namespace android {
     16 
     17 namespace base {
     18 class String;
     19 }  // namespace base
     20 
     21 namespace kernel {
     22 
     23 // Type of a function used to retrieve the textual description of a given
     24 // file at |filePath|. On success, return true and sets |*text| to the
     25 // description text, as if running through the 'file' command on Unix.
     26 // |opaque| is a client-provided value set by calling
     27 // setFileDescriptionFunction() below.
     28 typedef bool (GetFileDescriptionFunction)(void* opaque,
     29                                           const char* filePath,
     30                                           android::base::String* text);
     31 
     32 // Change the implementation of the function that extracts textual
     33 // descriptions from a given file. |file_func| is a pointer to the
     34 // new function, and |file_opaque| is the value that will be passed
     35 // as its first parameter. Note that if |file_func| is NULL, the
     36 // default implementation will be selected instead.
     37 //
     38 // Only use this during unit-testing to force different description
     39 // values on arbitrary file content.
     40 void setFileDescriptionFunction(GetFileDescriptionFunction* file_func,
     41                                 void* file_opaque);
     42 
     43 }  // namespace kernel
     44 
     45 }  // namespace android
     46 
     47 #endif  // ANDROID_KERNEL_KERNEL_UTILS_TESTING_H
     48