From: kernelnewbies-boun...@kernelnewbies.org 
[mailto:kernelnewbies-boun...@kernelnewbies.org] On Behalf Of Kenneth Adam 
Miller
Sent: Friday, February 20, 2015 12:49 PM
To: kernelnewbies@kernelnewbies.org
Subject: Re: Kernel Mocking

Well I think that a function or system call semantics replacement facility 
would be useful to unit testers everywhere. It would be benign of course, 
requiring that the unit testing framework request of the kernel that it replace 
the kernel facilities specified prior to the test, and automatically replace 
them afterward. So, this isn't anything akin to doing anything malicious, it 
requires user cooperation in order to hook. It's not like something forcibly 
done. I'm thinking of an intel pin for kernel level code.

Kenneth,

Please refrain from top posting. 8^)

I was just thinking you might be able to leverage that gcc profiling mcount() 
function trick that ftrace uses.

I don’t understand that well enough to say whether it would be applicable for 
what you want to do,
but it would be something you could look into. You should check out ftrace in 
any case if you are
interested in this kind of thing. It’s a way cool facility and comes already 
enabled on many distros.

Jeff Haran

On Fri, Feb 20, 2015 at 3:45 PM, Greg KH 
<g...@kroah.com<mailto:g...@kroah.com>> wrote:
On Fri, Feb 20, 2015 at 03:26:40PM -0500, Kenneth Adam Miller wrote:
> Thanks for your expedient answer!
>
> So, I was discussing an alternative to mocking; function hooking. But in a
> benign way. Is there any way to, at runtime replace the functionality of code
> in order that you specify what it does for any given kernel function?

Not really, but there are some hacks you can do if you _really_ know
what you are doing.

Hint, don't do this, just write "normal" tests for your kernel code, we
have lots of them already in the source tree, look in tools/selftests/.

Best of luck,

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Reply via email to