Skip to content

Some fixes in Python fuzzer logic #1922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 10, 2023
Merged

Some fixes in Python fuzzer logic #1922

merged 5 commits into from
Mar 10, 2023

Conversation

tochilinak
Copy link
Member

@tochilinak tochilinak commented Mar 10, 2023

Description

Changes:

  • New logic for functions with default arguments: first try to fuzz only positional arguments, then all of them.
  • Added new Python tree node: FakeNode (instead of Java null). If fuzzer provides object with this node, we don't start execution with this data.
  • BaselineAlgorithm now provides random type each 6 iterations.
  • Logic for abstract classes is now the same as for protocols.

How to test

Manual tests

Default arguments: https://github.com/TheAlgorithms/Python/blob/master/machine_learning/gradient_descent.py (function _error).

Random type: https://github.com/TheAlgorithms/Python/blob/master/data_structures/queue/circular_queue.py (function enqueue of class CircularQueue). Mypy does not pass any types for data parameter, bacause it consideres self.array to be list[None].

Test for abstract class:

from typing import AbstractSet

def id_(x: AbstractSet[int]):
    return x

Generated output:

import sys
sys.path.append(r'../../../utbot-python/samples/easy_samples')
import builtins
import general
import unittest


class TestTopLevelFunctions(unittest.TestCase):
    # region Test suites for executable general.id_
    
    # region FUZZER
    
    def test_id_(self):
        """
        x = builtins.set[typing.Any]
        """
        actual = general.id_(set())
        
        self.assertEqual(set(), actual)
    # endregion
    
    # endregion

Self-check list

Check off the item if the statement is true. Hint: [x] is a marked item.

Please do not delete the list or its items.

  • I've set the proper labels for my PR (at least, for category and component).
  • PR title and description are clear and intelligible.
  • I've added enough comments to my code, particularly in hard-to-understand areas.
  • The functionality I've repaired, changed or added is covered with automated tests.
  • Manual tests have been provided optionally.
  • The documentation for the functionality I've been working on is up-to-date.

@tochilinak tochilinak added ctg-enhancement New feature, improvement or change request comp-fuzzing Issue is related to the fuzzing lang-python Issue is related to python support labels Mar 10, 2023
@tochilinak tochilinak self-assigned this Mar 10, 2023
@tochilinak tochilinak merged commit 21f06bb into main Mar 10, 2023
@tochilinak tochilinak deleted the tochilinak/fuzzer_logic branch March 10, 2023 11:56
tamarinvs19 pushed a commit that referenced this pull request Mar 15, 2023
* FakeNode as empty object; fuzzing for abstract classes

* Better handling of default arguments

* Random type before each 6th iteration of BaselineAlgorithm

* Fixed subtype fuzzing

* small fixes
@alisevych alisevych added this to the 2023.03 Release milestone Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-fuzzing Issue is related to the fuzzing ctg-enhancement New feature, improvement or change request lang-python Issue is related to python support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants