CN105528292A - Kernel unit test method and system based on kernel module - Google Patents

Kernel unit test method and system based on kernel module Download PDF

Info

Publication number
CN105528292A
CN105528292A CN201510890501.6A CN201510890501A CN105528292A CN 105528292 A CN105528292 A CN 105528292A CN 201510890501 A CN201510890501 A CN 201510890501A CN 105528292 A CN105528292 A CN 105528292A
Authority
CN
China
Prior art keywords
kernel
test
unit
module
test procedure
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201510890501.6A
Other languages
Chinese (zh)
Inventor
卓维晨
李雪生
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Beijing Electronic Information Industry Co Ltd
Original Assignee
Inspur Beijing Electronic Information Industry Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inspur Beijing Electronic Information Industry Co Ltd filed Critical Inspur Beijing Electronic Information Industry Co Ltd
Priority to CN201510890501.6A priority Critical patent/CN105528292A/en
Publication of CN105528292A publication Critical patent/CN105528292A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The present invention discloses a kernel unit test method and system based on a kernel module. The method comprises the steps of compiling kernel codes which are developed by technical personnel and used for test, and obtaining test program; using the test program as a kernel module and installing the test program to a system kernel; and in the kernel space, utilizing the test program used as the kernel module, and directly calling the corresponding kernel function for kernel unit test. The dependence on kernel special logic indirect call is avoided, compared with the prior art that the kernel function is indirectly executed through system call, isolation generated by system call is effectively avoided, the probability of finding bug is increased, and therefore test requirements are satisfied.

Description

A kind of kernel unit method of testing based on kernel module and system
Technical field
The present invention relates to computer software testing technical field, particularly relate to a kind of kernel unit method of testing based on kernel module and system.
Background technology
At present, unit test method development for a long time, but because workload is large, testing progress is by problems such as coding affect, a lot of small-to-medium business does not all carry out the work of this respect, especially, for kernel, unit testing difficulty is larger, and the company that the domestic overwhelming majority does kernel development does not all have unit testing link.
For kernel, the quality of kernel coding will directly have influence on the stability of system cloud gray model, and therefore, carry out kernel unit test to the kernel code of exploitation, Timeliness coverage problem is only most important.Wherein, unit testing can help some system testings of developer's Timeliness coverage to be difficult to the problem found, for kernel development personnel Timeliness coverage bug provides strong help.
With regard to current technology, unit testing is all be used in the test to User space program, such as tests the piling of User space program.This method can only be used in the test of user program, and the unit testing of existing maturation is also all be used in User space, and the test for kernel state is substantially all also the stage resting on system testing.This has also just occurred much arriving curstomer's site just detectable problem, has not only interrupted normal development plan, and has brought a kind of very large pressure to developer.
Based on this, need badly and a kind ofly can avoid the isolation because system call produces (system call can shield some problems and cause technician can not Timeliness coverage), improve the probability finding bug, and then reach the new kernel unit method of testing of test request.
Summary of the invention
In view of this, the invention provides a kind of kernel unit method of testing based on kernel module and system, to avoid the isolation because system call produces, improve the probability finding bug, and then reach test request.
For solving the problems of the technologies described above, the invention provides a kind of kernel unit method of testing based on kernel module, comprising:
The kernel code for testing of technique of compiling staff development, obtains test procedure;
Using described test procedure as kernel module, be mounted in system kernel;
In kernel spacing, utilize the described test procedure as described kernel module, directly call corresponding kernel function and carry out kernel unit test.
In said method, preferably, when receiving the test sign on from the user program of user's space, utilizing the described test procedure as described kernel module, directly calling corresponding kernel function and carrying out kernel unit test.
In said method, preferably, described utilization, as the described test procedure of described kernel module, is directly called corresponding kernel function and is carried out kernel unit test, comprising:
The test data that reception technique personnel input to described user program;
Described test data is passed to the data-interface of described test procedure, makes described test procedure carry out the kernel unit corresponding with described test data test by directly calling the kernel function corresponding to described test data.
In said method, preferably, at the described test procedure of described utilization as described kernel module, directly call corresponding kernel function carry out kernel unit test time, also comprise:
To described user program feedback test result.
In said method, preferably, the daily record that described system kernel exports is fed back to described user program as test result.
Present invention also offers a kind of kernel unit test macro based on kernel module, comprising:
Compilation unit, for the kernel code for testing of technique of compiling staff development, obtains test procedure;
Installation unit, for using described test procedure as kernel module, be mounted in system kernel;
Test cell, in kernel spacing, utilizes the described test procedure as described kernel module, directly calls corresponding kernel function and carry out kernel unit test.
In said system, preferably, described test cell, specifically for when receiving the test sign on from the user program of user's space, utilizes the described test procedure as described kernel module, directly calls corresponding kernel function and carries out kernel unit test.
In said system, preferably, described test cell comprises:
Receive subelement, for the test data that reception technique personnel input to described user program;
Test subelement, for described test data being passed to the data-interface of described test procedure, makes described test procedure carry out the kernel unit corresponding with described test data test by directly calling the kernel function corresponding to described test data.
In said system, preferably, also comprise:
Feedback unit, at the described test procedure of described utilization as described kernel module, directly calls corresponding kernel function when carrying out kernel unit test, to described user program feedback test result.
In said system, preferably, described feedback unit feeds back to described user program specifically for the daily record exported by described system kernel as test result.
Above in a kind of kernel unit method of testing based on kernel module provided by the invention and system, the kernel code for testing of technique of compiling staff development, obtains test procedure; Using described test procedure as kernel module, be mounted in system kernel; In kernel spacing, utilize the described test procedure as described kernel module, directly call corresponding kernel function and carry out kernel unit test, span the dependence to the indirect call of kernel specific logical, compare in prior art and indirectly perform kernel function by system call, effectively prevent the isolation because system call produces, improve the probability finding bug, and then reach test request.
Accompanying drawing explanation
In order to be illustrated more clearly in the embodiment of the present invention or technical scheme of the prior art, be briefly described to the accompanying drawing used required in embodiment or description of the prior art below, apparently, accompanying drawing in the following describes is only embodiments of the invention, for those of ordinary skill in the art, under the prerequisite not paying creative work, other accompanying drawing can also be obtained according to the accompanying drawing provided.
The process flow diagram of a kind of kernel unit method of testing based on kernel module that Fig. 1 provides for the embodiment of the present invention;
Fig. 2 adopts system call mode to carry out the application scenarios process flow diagram tested in prior art;
The application scenarios process flow diagram of a kind of kernel unit method of testing based on kernel module that Fig. 3 provides for the embodiment of the present invention;
The structured flowchart schematic diagram of a kind of kernel unit test macro based on kernel module that Fig. 4 provides for the embodiment of the present invention.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, be clearly and completely described the technical scheme in the embodiment of the present invention, obviously, described embodiment is only the present invention's part embodiment, instead of whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtained under creative work prerequisite, belong to the scope of protection of the invention.
Core of the present invention is to provide a kind of kernel unit method of testing based on kernel module and system, to avoid the isolation because system call produces, improves the probability finding bug, and then reaches test request.
In order to make those skilled in the art person understand the present invention program better, below in conjunction with the drawings and specific embodiments, the present invention is described in further detail.
Show the process flow diagram of a kind of kernel unit method of testing based on kernel module that the embodiment of the present invention provides with reference to figure 1, Fig. 1, the method specifically can comprise the steps:
The kernel code for testing of step S100, technique of compiling staff development, obtains test procedure.
Step S101, using test procedure as kernel module, be mounted in system kernel.
In the present invention, the test procedure as kernel module is called kernel test module.
Want to allow test procedure directly call kernel function, need to adopt the module of writing similar driving, dynamically insert with the form of kernel module and be installed to system kernel, this method also need not recompilate kernel mirror image, directly simple, and normally can unload with the module unloading manner of routine, in specific implementation process, the compression and decompression of the module of specifying can be completed by insmod/rmmod order.
Step S102, in kernel spacing, utilize the test procedure as kernel module, directly call corresponding kernel function and carry out kernel unit test.
In actual applications, test procedure can not run immediately as the module of kernel after inserting kernel, the kernel module of the user program of user's space to kernel spacing is had to control, namely need User space to issue test sign on could run, want here can realize by the flexible control of user program to test procedure.Therefore, when receiving the test sign on from the user program of user's space, utilizing the test procedure as kernel module, directly calling corresponding kernel function and carrying out kernel unit test.
It is mutual that the above-mentioned initiation to test procedure needs between kernel spacing and user's space, same, although test procedure can realize several scenes, the test of multiple situation, but these all will import different test datas into by user program and could trigger, and these data are just from the input of client layer.The specific implementation process of above-mentioned steps S102 is as follows:
First, the test data that inputs to user program of reception technique personnel; Then, test data is passed to the data-interface of test procedure, makes test procedure carry out the kernel unit corresponding with test data test by directly calling the kernel function corresponding to test data.
Referring to figs. 2 and 3, Fig. 2 shows in a kind of prior art and adopts system call mode to carry out the application scenarios process flow diagram tested, and Fig. 3 shows the application scenarios process flow diagram of a kind of kernel unit method of testing based on kernel module that the embodiment of the present invention provides.In fig. 2, user program directly enters kernel by system call, test kernel.And in figure 3, user program enters kernel by the test procedure called as kernel module, kernel module directly calls kernel function and tests, and the four-headed arrow in figure is the reciprocal process of user's space and kernel spacing.For other content in figure, be not emphasis place of the present invention, with reference to prior art, can not do too much elaboration herein.
In addition, understand the result of test for the ease of technician, while carrying out kernel unit test, to user program feedback test result, further, the daily record that system kernel exports can be fed back to user program as test result.This is because in actual applications, the daily record that kernel can be run by printk register system, technician can by checking that the log that system journal or kernel export sees.Certainly, also can pass to user program, feed back to user by user program.
To sum up, utilize the test procedure as kernel module, directly call corresponding kernel function and carry out kernel unit test, span the dependence to the indirect call of kernel specific logical, compare in prior art and indirectly perform kernel function by system call, effectively prevent the isolation because system call produces, improve the probability finding bug, and then reach test request.
Based on the kernel unit method of testing based on kernel module that the invention described above embodiment provides, the embodiment of the present invention additionally provides a kind of kernel unit test macro based on kernel module, and with reference to figure 4, this system 400 can comprise following content:
Compilation unit 401, for the kernel code for testing of technique of compiling staff development, obtains test procedure;
Installation unit 402, for using test procedure as kernel module, be mounted in system kernel;
Test cell 403, in kernel spacing, utilizes the test procedure as kernel module, directly calls corresponding kernel function and carries out kernel unit test.
In the present invention, test cell 403 specifically may be used for, when receiving the test sign on from the user program of user's space, utilizing the test procedure as kernel module, directly calls corresponding kernel function and carries out kernel unit test.
Further, test cell 403 specifically can comprise following content:
Receive subelement, for the test data that reception technique personnel input to user program;
Test subelement, for test data being passed to the data-interface of test procedure, makes test procedure carry out the kernel unit corresponding with test data test by directly calling the kernel function corresponding to test data.
In the present invention, said system 400 specifically can also comprise feedback unit, for utilizing as the test procedure of kernel module, directly calls corresponding kernel function when carrying out kernel unit test, to user program feedback test result.
Further, above-mentioned feedback unit feeds back to user program specifically for the daily record exported by system kernel as test result.
It should be noted that, each embodiment in this instructions all adopts the mode of going forward one by one to describe, and what each embodiment stressed is the difference with other embodiment, between each embodiment identical similar part mutually see.For system class embodiment, due to itself and embodiment of the method basic simlarity, so describe fairly simple, relevant part illustrates see the part of embodiment of the method.
Above a kind of kernel unit method of testing based on kernel module provided by the present invention and system are described in detail.Apply specific case herein to set forth principle of the present invention and embodiment, the explanation of above embodiment just understands method of the present invention and core concept thereof for helping.It should be pointed out that for those skilled in the art, under the premise without departing from the principles of the invention, can also carry out some improvement and modification to the present invention, these improve and modify and also fall in the protection domain of the claims in the present invention.

Claims (10)

1., based on a kernel unit method of testing for kernel module, it is characterized in that, comprising:
The kernel code for testing of technique of compiling staff development, obtains test procedure;
Using described test procedure as kernel module, be mounted in system kernel;
In kernel spacing, utilize the described test procedure as described kernel module, directly call corresponding kernel function and carry out kernel unit test.
2. the method for claim 1, is characterized in that,
When receiving the test sign on from the user program of user's space, utilizing the described test procedure as described kernel module, directly calling corresponding kernel function and carrying out kernel unit test.
3. method as claimed in claim 2, it is characterized in that, described utilization, as the described test procedure of described kernel module, is directly called corresponding kernel function and is carried out kernel unit test, comprising:
The test data that reception technique personnel input to described user program;
Described test data is passed to the data-interface of described test procedure, makes described test procedure carry out the kernel unit corresponding with described test data test by directly calling the kernel function corresponding to described test data.
4. the method as described in claims 1 to 3 any one, is characterized in that, at the described test procedure of described utilization as described kernel module, directly call corresponding kernel function carry out kernel unit test time, also comprise:
To described user program feedback test result.
5. method as claimed in claim 4, it is characterized in that, the daily record exported by described system kernel feeds back to described user program as test result.
6., based on a kernel unit test macro for kernel module, it is characterized in that, comprising:
Compilation unit, for the kernel code for testing of technique of compiling staff development, obtains test procedure;
Installation unit, for using described test procedure as kernel module, be mounted in system kernel;
Test cell, in kernel spacing, utilizes the described test procedure as described kernel module, directly calls corresponding kernel function and carry out kernel unit test.
7. system as claimed in claim 6, it is characterized in that, described test cell, specifically for when receiving the test sign on from the user program of user's space, utilizes the described test procedure as described kernel module, directly calls corresponding kernel function and carries out kernel unit test.
8. system as claimed in claim 7, it is characterized in that, described test cell comprises:
Receive subelement, for the test data that reception technique personnel input to described user program;
Test subelement, for described test data being passed to the data-interface of described test procedure, makes described test procedure carry out the kernel unit corresponding with described test data test by directly calling the kernel function corresponding to described test data.
9. the system as described in claim 6 to 8 any one, is characterized in that, also comprises:
Feedback unit, at the described test procedure of described utilization as described kernel module, directly calls corresponding kernel function when carrying out kernel unit test, to described user program feedback test result.
10. system as claimed in claim 9, it is characterized in that, described feedback unit feeds back to described user program specifically for the daily record exported by described system kernel as test result.
CN201510890501.6A 2015-12-07 2015-12-07 Kernel unit test method and system based on kernel module Pending CN105528292A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510890501.6A CN105528292A (en) 2015-12-07 2015-12-07 Kernel unit test method and system based on kernel module

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510890501.6A CN105528292A (en) 2015-12-07 2015-12-07 Kernel unit test method and system based on kernel module

Publications (1)

Publication Number Publication Date
CN105528292A true CN105528292A (en) 2016-04-27

Family

ID=55770535

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510890501.6A Pending CN105528292A (en) 2015-12-07 2015-12-07 Kernel unit test method and system based on kernel module

Country Status (1)

Country Link
CN (1) CN105528292A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114676069A (en) * 2022-05-30 2022-06-28 深圳市科力锐科技有限公司 Kernel file testing method, device, equipment and storage medium
CN115033497A (en) * 2022-08-11 2022-09-09 北京登临科技有限公司 Kernel function testing method, device, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101634965A (en) * 2008-07-24 2010-01-27 三星电子(中国)研发中心 Method for testing Linux kernel-grade unit
US7949901B2 (en) * 2007-03-26 2011-05-24 Fujitsu Limited Program and apparatus for generating system test specifications
KR20140072726A (en) * 2012-12-05 2014-06-13 경북대학교 산학협력단 Function Test Apparatus based on Unit Test Cases Reusing and Function Test Method thereof
CN104915292A (en) * 2015-06-12 2015-09-16 浪潮电子信息产业股份有限公司 Method for dynamically piling Linux kernel module
CN105068937A (en) * 2015-09-22 2015-11-18 浪潮(北京)电子信息产业有限公司 Unit test method of Linux kernel module

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7949901B2 (en) * 2007-03-26 2011-05-24 Fujitsu Limited Program and apparatus for generating system test specifications
CN101634965A (en) * 2008-07-24 2010-01-27 三星电子(中国)研发中心 Method for testing Linux kernel-grade unit
KR20140072726A (en) * 2012-12-05 2014-06-13 경북대학교 산학협력단 Function Test Apparatus based on Unit Test Cases Reusing and Function Test Method thereof
CN104915292A (en) * 2015-06-12 2015-09-16 浪潮电子信息产业股份有限公司 Method for dynamically piling Linux kernel module
CN105068937A (en) * 2015-09-22 2015-11-18 浪潮(北京)电子信息产业有限公司 Unit test method of Linux kernel module

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
梁金昆等: "《IA-64 Linux 内核设计与实现》", 30 November 2004, 清华大学出版社 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114676069A (en) * 2022-05-30 2022-06-28 深圳市科力锐科技有限公司 Kernel file testing method, device, equipment and storage medium
CN114676069B (en) * 2022-05-30 2022-08-30 深圳市科力锐科技有限公司 Kernel file testing method, device, equipment and storage medium
CN115033497A (en) * 2022-08-11 2022-09-09 北京登临科技有限公司 Kernel function testing method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN109325195B (en) Rendering method and system for browser, computer device and computer storage medium
US9372784B2 (en) Test system configuration method and system
CN105159833A (en) Automatic testing device and method
CN106708718B (en) Service framework interface test method and device
US20150100832A1 (en) Method and system for selecting and executing test scripts
US10042744B2 (en) Adopting an existing automation script to a new framework
US20150100830A1 (en) Method and system for selecting and executing test scripts
CN108255708B (en) Method, device, storage medium and equipment for accessing production file in test environment
CN102968371B (en) The method of test JAVA API unit component and device
US20150100831A1 (en) Method and system for selecting and executing test scripts
CN103927256A (en) Method for controlling multiple Android devices
US10310964B2 (en) System and method for determining relevance of application software maintenance
CN112579569A (en) Data migration method and device
US9311215B2 (en) Defining multi-channel tests system and method
CN105528292A (en) Kernel unit test method and system based on kernel module
WO2019237239A1 (en) Data test method and apparatus, device/terminal/server and computer readable storage medium
CN103546342B (en) A kind of terminal consistency test method and the api interface universal adapter for the method
CN108536429B (en) Method and device for developing software, storage medium and electronic equipment
CN103631585A (en) Method and system for developing application program
US10176062B2 (en) Cloud servers and methods for handling dysfunctional cloud services
CN103034501A (en) Function calling method and function calling device for linux platform
CN110795330A (en) Monkey pressure testing method and device
CN104965780A (en) Data processing method and system
CN112099814B (en) System and method for managing vehicle-mounted machine application software installation environment
CN104102575A (en) On-line debugging method

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20160427