[PATCH] samba-tool throws error if there is an empty FSMO role

Andreas Schneider asn at samba.org
Tue May 10 09:41:13 UTC 2016


On Monday, May 09, 2016 07:04:44 PM Rowland Penny wrote:
> On 05/05/16 18:22, Andrew Bartlett wrote:
> > On Thu, 2016-05-05 at 15:05 +0100, Rowland Penny wrote:
> >> OK, so I re-read all Andrews posts, decided to try to do what he
> >> said,
> >> set up the testenv and see what happens with the stock fsmo.py.
> >> He said:
> >> 
> >> If you run "SELFTEST_TESTENV=fl2000dc:local make testenv"
> >> 
> >> Then you can play in that environment.
> >> 
> >> so I tried that and it wouldn't work, but the error message told what
> >> was wrong, I wasn't in the root dir of the Samba tarball.
> >> 
> >> Moved there and tried again:
> >> SELFTEST_TESTENV=fl2000dc:local make testenv
> >> 
> >> and got this:
> >> 
> >> Waf: Leaving directory `/usr/src/samba/samba-4.4.3/bin'
> >> 'build' finished successfully (4m12.098s)
> >> ERROR: You must use --enable-selftest to enable selftest
> >> Makefile:27: recipe for target 'testenv' failed
> >> make: *** [testenv] Error 1
> >> 
> >> So from this, I think I will need to do this:
> >> 
> >> Download Samba tarball
> >> Unpack tarball
> >> cd into directory created
> >> run './configure --enable-selftest' along with any other configure
> >> options I require
> >> make
> >> SELFTEST_TESTENV=fl2000dc:local make testenv
> >> 
> >> Is this correct ??
> > 
> > Pretty much.  I would check out git master instead, as that is what you
> > will be patching, and run ./configure.developer rather than ./configure
> > --enable-selftest (due to other reported bugs I've not yet dug into,
> > and we don't want to get into here), but otherwise, that is correct.
> > 
> > Thanks!
> > 
> > Andrew Bartlett
> 
> OK, I have tried, but I just don't understand how the tests are supposed
> to work, it looks like 'selftest.pl' calls various other scripts and
> runs a test script that ultimately tests something (in my case,
> fsmo.py). writing a script to actually run 'samba-tool fsmo show' should
> be fairly easy, but the bits in-between are defeating me. it doesn't
> help that whilst looking in the various 'selftest' directories, I am
> finding perl, python and bash scripts. I can understand the last two,
> but perl, well this is a foreign language to me and I don't speak any
> foreign languages :-)
> 
> Is there an idiots guide to writing Samba tests ??? The idiot being me :-D
> 
> Rowland

I gave a talk at SambaXP about selftest last year. It has some pictures which 
help to understand it:


https://sambaxp.org/archive_data/SambaXP2015-SLIDES/thu/track3/sambaxp2015-thu-track3-Andreas_Schneider-HowToUseTheSambaSelftestSuite.pdf

Tests are run against a target. A target is e.g.: ad_dc, fl2008r2dc, ...

You can get a list of possible targets doing:

	grep "sub setup_" selftest/target/Samba4.pm

A test is an executable (shell script, python script, ...) scheduled against a 
target (fl2008r2dc e.g. is a functional level 2008r2 ad_dc).

You schedule a test (executable or script) against a target in 
source4/selftest/tests.py

For test development it is useful to run 'make testenv' (like explained by 
Andrew earlier). Using the testenv you can execute the test (executable or 
script) directly in the test environment while writing it. It makes test 
development easier.


Once you planned the test in source4/selftest/tests.py you can do:

	make test TESTS="testname"

To only execute one test.




	Untested code is broken code :)



	-- andreas



More information about the samba-technical mailing list