GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - file/file-tests: File-tests is test-suite for File tool. Previous home: https://fedorahosted.org/file-tests/

BranchesTags
Open more actions menu

Latest commit

 

History

201 Commits
201 Commits

Folders and files

NameName
Last commit message
Last commit date
db
db
 
 
pyfile
pyfile
 
 
rpm-fileattrs
rpm-fileattrs
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
AUTHORS
AUTHORS
 
 
CONTRIBUTING
CONTRIBUTING
 
 
COPYING
COPYING
 
 
Makefile
Makefile
 
 
PURPOSE
PURPOSE
 
 
README
README
 
 
compare-db.py
compare-db.py
 
 
convert-pickle-db.py
convert-pickle-db.py
 
 
fast-regression-test.py
fast-regression-test.py
 
 
gh-file-hook.php
gh-file-hook.php
 
 
review-patch.py
review-patch.py
 
 
runtest.sh
runtest.sh
 
 
test-file.py
test-file.py
 
 
test-rpmbuild-regression.py
test-rpmbuild-regression.py
 
 
update-db.py
update-db.py
 
 

Repository files navigation

==============================================================================
================== File-tests - File regressions detection ===================
==============================================================================

Author: Jan Kaluza <[email protected]>



1) WHY IS IT USEFUL?
====================

It's not possible to check the regressions between File releases manually and
unfortunatelly File can't work 100% and even a small change in one magic pattern
can cause a big regression.

This project aims to make comparing outputs of different File versions easier
and provides database of files in different formats.



2) HOW TO USE IT?
=================

This howto presumes that CWD is the root of the git repository (the same
directory as this README file is in).

2.1: Prepare the Magdir:
------------------------

You have to provide the Magdir directory with magic patterns from the File
sources of the exactly the same File version as you want to test. This is
needed to identify particular magic pattern responsible for the particular
file detection.

You can just copy Magdir into the CWD:

$ cp -pr /path/to/file/magic/Magdir ./

2.2: Update the database with the current/old File version:
-----------------------------------------------------------

Note that this whole procedure needs 3.5GB free space, because
patterns are splitted and compiled by file individually. See
HOW DOES IT WORK section for more details.

$ python update-db.py <unique-name> [path_to_magdir]

So in our case for example:

$ python update-db.py file-5.07 Magdir

2.3: Install new File version you want to test regressions against:
-------------------------------------------------------------------

$ sudo rpm -U my-file.prm my-file-libs.rpm ...

2.4: Run fast-regression-test:
------------------------------

Fast regression test tests the output of the currently installed File and
compares it to the one stored in db/*/*.json files. If there's a significant
difference (see HOW DOES IT WORK) between the output, it's showed as FAIL.

$ python fast-regression-test.py

If you run this test with "exact" argument, particular test will FAIL even
if there's small change in the File output.

2.5: Identify patterns causing the regressions:
-----------------------------------------------

With compare-db.py script, you can get the patterns causing the regression.
At first you have to prepare the Magdir from the current File version as
mentioned in step "2.1: Prepare the Magdir".

Note that this whole procedure needs 3.5GB free space, because
patterns are splitted and compiled by file individually. See
HOW DOES IT WORK section for more details.

$ python compare-db.py <unique-name> [path_to_magdir]

So in our case for example:

$ python compare-db.py file-5.10 Magdir

If you run this test with "exact" argument, particular test will FAIL even
if there's small change in the File output:

$ python compare-db.py file-5.10 Magdir exact
or
$ python compare-db.py file-5.10 exact



3) HOW DOES IT WORK?
====================

There is database of files in "db" directory.

3.1: update.db script:
----------------------

At first, this script splits all the patterns from Magdir directory into
separated files, so there is one magic pattern per file. Those files are
stored into ./.mgc_temp/<file_name_hash>/output.

After that, patterns are compiled using this algorithm:

N = 0
pattern_to_compile = ""
for every pattern:
	pattern_to_compile += pattern
	compile pattern_to_compile
	save it as ./.mgc_temp/<file_name_hash>/.find-magic.tmp.N
	N++

Then all files in the db directory are detected. During the detection,
particular pattern responsible for detection is found using the bisection
method.

All metadata are stored into ./db/*/*.json file.

3.2: fast-regression-test.py script:
------------------------------------

This script simply gets metadata stored in the ./db/*/*.json files and
compares them with the output of the current File version.

In non-exact mode, regressions are detected using the Ratcliff/Obershelp
pattern recognition implemented by difflib.SequenceMatcher Python module.
The regression is detected if the ratio returned by the SequenceMatcher is
lower than 0.7.

In exact mode, the old and new output have to match exactly.

3.3: compare-db.py script:
--------------------------

This script does the same work as update.db script, but instead of storing
metadata into ./db directory, it compares them with the metadata already
stored in ./db directory by previously run update-db.py script.

Comparison is done the same way as in fast-regression-test.py script.

About

File-tests is test-suite for File tool. Previous home: https://fedorahosted.org/file-tests/

Resources

Readme
GPL-2.0 license

Contributing

Contributing
Activity
Custom properties

Stars

21 stars

Watchers

5 watching

Forks

11 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.