[zypp-commit] r8167 - in /trunk/sat-solver/bindings: ruby/tests/solutions.rb satsolver.i
Author: kkaempf Date: Mon Dec 31 16:13:29 2007 New Revision: 8167 URL: http://svn.opensuse.org/viewcvs/zypp?rev=8167&view=rev Log: add solution testcase workaround swigs rename of Xn -> X_n Added: trunk/sat-solver/bindings/ruby/tests/solutions.rb Modified: trunk/sat-solver/bindings/satsolver.i Added: trunk/sat-solver/bindings/ruby/tests/solutions.rb URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/ruby/tests/solutions.rb?rev=8167&view=auto ============================================================================== --- trunk/sat-solver/bindings/ruby/tests/solutions.rb (added) +++ trunk/sat-solver/bindings/ruby/tests/solutions.rb Mon Dec 31 16:13:29 2007 @@ -0,0 +1,112 @@ +$: << "../../../build/bindings/ruby" +# test Solutions +require 'test/unit' +require 'satsolver' + +class SolutionTest < Test::Unit::TestCase + def test_solutions + pool = SatSolver::Pool.new + assert pool + + installed = pool.create_repo( 'system' ) + assert installed + installed.create_solvable( 'A', '0.0-0' ) + installed.create_solvable( 'B', '1.0-0' ) + solv = installed.create_solvable( 'C', '2.0-0' ) + solv.requires << SatSolver::Relation.new( pool, "D", SatSolver::REL_EQ, "3.0-0" ) + installed.create_solvable( 'D', '3.0-0' ) + + repo = pool.create_repo( 'test' ) + assert repo + + solv1 = repo.create_solvable( 'A', '1.0-0' ) + assert solv1 + solv1.obsoletes << SatSolver::Relation.new( pool, "C" ) + solv1.requires << SatSolver::Relation.new( pool, "B", SatSolver::REL_GT, "2.0-0" ) + + solv2 = repo.create_solvable( 'B', '2.0-0' ) + assert solv2 + + solv3 = repo.create_solvable( 'CC', '3.3-0' ) +# solv3.requires << SatSolver::Relation.new( pool, "Z" ) + repo.create_solvable( 'DD', '4.4-0' ) + + + transaction = pool.create_transaction + transaction.install( solv1 ) + transaction.remove( "Z" ) + + solver = pool.create_solver( installed ) +# solver.allow_uninstall = 1; +# @pool.debug = 255 + solver.solve( transaction ) + assert solver.problems? + puts "Problems found" + i = 0 + solver.each_problem( transaction ) { |p| + i += 1 + case p.reason + when SatSolver::SOLVER_PROBLEM_UPDATE_RULE + reason = "problem with installed" + when SatSolver::SOLVER_PROBLEM_JOB_RULE + reason = "conflicting requests" + when SatSolver::SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP + reason = "nothing provides requested" + when SatSolver::SOLVER_PROBLEM_NOT_INSTALLABLE + reason = "not installable" + when SatSolver::SOLVER_PROBLEM_NOTHING_PROVIDES_DEP + reason = "nothing provides rel required by source" + when SatSolver::SOLVER_PROBLEM_SAME_NAME + reason = "cannot install both" + when SatSolver::SOLVER_PROBLEM_PACKAGE_CONFLICT + reason = "source conflicts with rel provided by target" + when SatSolver::SOLVER_PROBLEM_PACKAGE_OBSOLETES + reason = "source obsoletes rel provided by target" + when SatSolver::SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE + reason = "source requires rel but no providers are installable" + else + reason = "**unknown**" + end + puts "#{i}: [#{reason}] Source #{p.source}, Rel #{p.relation}, Target #{p.target}" + j = 0 + p.each_solution { |s| + j += 1 + case s.solution + when SatSolver::SOLUTION_UNKNOWN + solution = "None available" + when SatSolver::SOLUTION_NOKEEP_INSTALLED + solution = "dont keep installed" + when SatSolver::SOLUTION_NOINSTALL_SOLV + solution = "dont install solvable" + when SatSolver::SOLUTION_NOREMOVE_SOLV + solution = "dont remove solvable" + when SatSolver::SOLUTION_NOFORBID_INSTALL + solution = "dont forbid install" + when SatSolver::SOLUTION_NOINSTALL_NAME + solution = "dont install name" + when SatSolver::SOLUTION_NOREMOVE_NAME + solution = "dont remove name" + when SatSolver::SOLUTION_NOINSTALL_REL + solution = "dont install relation" + when SatSolver::SOLUTION_NOREMOVE_REL + solution = "dont remove relation" + when SatSolver::SOLUTION_NOUPDATE + solution = "dont update" + when SatSolver::SOLUTION_ALLOW_DOWNGRADE + solution = "allow downgrade" + when SatSolver::SOLUTION_ALLOW_ARCHCHANGE + solution = "allow architecture change" + when SatSolver::SOLUTION_ALLOW_VENDORCHANGE + solution = "allow vendor change" + when SatSolver::SOLUTION_ALLOW_REPLACEMENT + solution = "allow replacement" + when SatSolver::SOLUTION_ALLOW_REMOVE + solution = "allow removal" + else + solution = "**UNKNOWN**" + end + puts " #{j}: [#{solution}] #{s.s1}" + } + } + end +end Modified: trunk/sat-solver/bindings/satsolver.i URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/bindings/satsolver.i?rev=8167&r1=8166&r2=8167&view=diff ============================================================================== --- trunk/sat-solver/bindings/satsolver.i (original) +++ trunk/sat-solver/bindings/satsolver.i Mon Dec 31 16:13:29 2007 @@ -1043,19 +1043,39 @@ /* Solution */ %extend Solution { - %constant int SOLUTION_UPDATE_RULE = 1; + %constant int SOLUTION_UNKNOWN = 0; + %constant int SOLUTION_NOKEEP_INSTALLED = 1; + %constant int SOLUTION_NOINSTALL_SOLV = 2; + %constant int SOLUTION_NOREMOVE_SOLV = 3; + %constant int SOLUTION_NOFORBID_INSTALL = 4; + %constant int SOLUTION_NOINSTALL_NAME = 5; + %constant int SOLUTION_NOREMOVE_NAME = 6; + %constant int SOLUTION_NOINSTALL_REL = 7; + %constant int SOLUTION_NOREMOVE_REL = 8; + %constant int SOLUTION_NOUPDATE = 9; + %constant int SOLUTION_ALLOW_DOWNGRADE = 10; + %constant int SOLUTION_ALLOW_ARCHCHANGE = 11; + %constant int SOLUTION_ALLOW_VENDORCHANGE = 12; + %constant int SOLUTION_ALLOW_REPLACEMENT = 13; + %constant int SOLUTION_ALLOW_REMOVE = 14; ~Solution() { free ($self); } int solution() { return $self->solution; } + /* without the %rename, swig converts it to 's_1'. Ouch! */ + %rename( "s1" ) s1( ); Solvable *s1() { return pool_id2solvable( $self->pool, $self->s1 ); } + %rename( "n1" ) n1( ); const char *n1() { return id2str( $self->pool, $self->n1 ); } + %rename( "r1" ) r1( ); Relation *r1() { return relation_new( $self->pool, $self->n1 ); } + %rename( "s2" ) s2( ); Solvable *s2() { return pool_id2solvable( $self->pool, $self->s2 ); } + %rename( "n2" ) n2( ); const char *n2() { return id2str( $self->pool, $self->n2 ); } } -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org
participants (1)
-
kkaempf@svn.opensuse.org