OUTPUT:
RETVAL
+bool
+flush_set(session, setname)
+ struct ipset_session *session;
+ const char *setname;
+
+ PREINIT:
+ enum ipset_cmd cmd = IPSET_CMD_FLUSH;
+
+ CODE:
+ // Assign the setname to the session data.
+ int r = ipset_session_data_set(session, IPSET_SETNAME, setname);
+ if (r < 0) {
+ goto ERROR;
+ }
+
+ r = ipset_cmd(session, cmd, 0);
+ if (r < 0) {
+ goto ERROR;
+ }
+
+ RETVAL = true;
+
+ goto END;
+
+ ERROR:
+ RETVAL = false;
+
+ // Reset session data.
+ ipset_data_reset(ipset_session_data(session));
+ END:
+ OUTPUT:
+ RETVAL
+
bool
setname_exists(session, setname)
struct ipset_session *session;
use strict;
use warnings;
-use Test::More tests => 19;
+use Test::More tests => 21;
BEGIN { use_ok('IPSet') };
#########################
ok($data->{entries} lt scalar(@addresses), "Less entries in the set than at the addresses array");
ok($data->{entries} gt 0, "At least one entry on the testset");
+# Flush the set.
+my $flush = &IPSet::flush_set($session, $testset{'name'});
+ok($flush, "Successfully flushed the testset.");
+
+# Update set data.
+$data = &IPSet::get_set_data($session, $testset{'name'});
+ok($data->{entries} eq 0, "No entries anymore in the testset.");
+
# CLEANUP: Delete the remaining set.
&IPSet::delete_set($session, $testset{'name'});